vue.js执行mounted的实例
<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title><
·
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<meta charset="utf-8" />
<script src="../js/vue.js"></script>
</head>
<body>
<div id="app">
<div>{{msg}}</div><button @click="ontime">start</button>
</div>
<script>
new Vue({
el: '#app',
data: { msg: 0 },
methods: {
ontime:function(){
setInterval(() => {
this.msg++;
}, 1000);
}
},
mounted: function () { this.ontime(); }
});
</script>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<meta charset="utf-8" />
<script src="../js/vue.js"></script>
</head>
<body>
<div id="app">
<div>{{msg}}</div><button @click="ontime">start</button>
</div>
<script>
new Vue({
el: '#app',
data: { msg: 0 },
methods: {
ontime:function(){
setInterval(() => {
this.msg++;
}, 1000);
}
},
mounted: function () { this.ontime(); }
});
</script>
</body>
</html>
更多推荐
已为社区贡献3条内容
所有评论(0)