1. 程式人生 > >vue頁面離開後執行函式

vue頁面離開後執行函式

destroyed: function () {
           console.log("我已經離開了!");
    this.stopTimer();
 },

說明:destroyed是與methods、mounted同層級的

mounted(){
    this.startTimer();
},
//離開當前頁面後執行
destroyed: function () {
    this.stopTimer();
},