將字幕簡單的跑起來,emmmm(類似大街上那種電子滾動屏效果)…
HTML代碼:
<!DOCTYPE html>
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<title>跑馬燈</title>
</head>
<body>
<div id="app">
<button v-on:click="gostart()">開始</button>
<button v-on:click="gostop()">停止</button>
<h3 v-html="info"></h3>
</div>
<script src="../lib/vue.js" type="application/javascript"></script>
<script type="text/javascript">
var vm=new Vue({
el: "#app",
data: {
info: "曉看天色暮看雲,行也思君,坐也思君...",
lightIntervalID:null
},
methods:{
gostart(){
console.log("shshhs");
if(this.lightIntervalID!=null){return;}
console.log();
var _this=this;
this.lightIntervalID=setInterval(function () {
_this.info=_this.info.substring(1).concat(_this.info.charAt(0));
},200);
},
gostop(){
clearInterval(this.lightIntervalID);
this.lightIntervalID = null;
}
}
})
</script>
</body>
</html>