vue v-on v-text 的运用

<!DOCTYPE html>
<html>
 <meta charset="utf-8">
<head>
    <title></title>
</head>
<script src="./vue.js" type="text/javascript" charset="utf-8"></script>
<body>
<div id="app">

<button type="" @click='show'>浪起来</button>
<button type="" @click='hide'>低调</button>
<div v-text='msg'></div>

</div>
<script type="text/javascript">
  var vm = new Vue({
       el:'#app',
       data:{
           'msg':'abckdefhigklmnopqrstuvwxyz',
           'intervalid':null
       },
       methods:{
           show:function(){
               if(this.intervalid == null){
                   this.intervalid=setInterval(() => {
                   var start = this.msg.substring(0,1)
                   var end = this.msg.substring(1)
                   this.msg=end + start
                   },300)                   
               }

           },
           hide:function(){
            clearInterval(this.intervalid)
            this.intervalid=null
           }
       }
   })
</script>
</body>
</html>

 

posted @ 2019-08-11 22:43  酷酷的城池  阅读(206)  评论(0编辑  收藏  举报