这个beforeDestroy
到底是什么意思?为什么下面代码beforeDestroy
里面的内容不执行?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="app">
{{date}}
</div>
<script>
var app=new Vue({
el:'#app',
data:{
date:new Date()
},
mounted() {
var _this=this;
_this.start=setInterval(function(params) {
_this.date=new Date();
},1000)
},
beforeDestroy() {
//清楚定时器
alert(1);
},
})
</script>
</body>
</html>
https://cn.vuejs.org/v2/guide...