v-on
进行事件的绑定,我们用的最多的是click事件绑定
简写@
实现跑马灯的效果
跑马灯简易效果
<script>
let vue = new Vue({
el:'#box',
data:{
msg:'我是4我是3我是2我是1',
timer:'null'
},
methods:{
start(){
clearInterval(this.timer)
this.timer = setInterval(()=>{
let first = this.msg.slice(0,1);
let second = this.msg.slice(1)
this.msg = second + first;
},100)
},
end(){
clearInterval(this.timer)
this.timer = null
}
},
})
</script>