<div id="app">
<button @click="go">走</button>
<button @click="stop">停</button>
<h3> {{msg}} </h3>
</div>
<script>
var vm=new Vue({
el:'#app',
data:{
msg:'123456789~~',
timer:null,
},
methods:{
go:function () {
if(this.timer!=null){
return;
}
var that=this;
this.timer=setInterval(function () {
var star=that.msg.substring(0,1);
var end=that.msg.substring(1);
that.msg=end+star;
return that.msg;
},400)
},
stop:function () {
clearInterval(this.timer);
this.timer=null;
}
}
})
</script>
Vue跑马灯效果(es5)
猜你喜欢
转载自blog.csdn.net/Zyl_CN/article/details/82797590
今日推荐
周排行