请皇上批阅
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>跑马灯</title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="app">
<input type="button" value="寻找" @click="search">
<input type="button" value="停止" @click="stop">
<h3>{{msg}}</h3>
</div>
<script>
var vm = new Vue({
el:'#app',
data: {
msg: '众里寻你!!!你却不知道~~~!',
intInterval: null
},
methods: {
search(){
if (this.intInteval != null)
return;
this.intInteval = setInterval( () => {
var start = this.msg.substring(0, 1);
var end = this.msg.substring(1);
this.msg = end + start;
}, 500)
},
stop(){
clearInterval(this.intInteval);
this.intInteval = null;
}
}
});
</script>
</body>
</html>