首页 > 其他 > 详细

vue 跑马灯效果

时间:2021-09-08 20:56:41      阅读:10      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
    </head>
    <body>
        <div id="app">
            <div>{{msg}}</div>
            <button @click="lang">浪起来</button>
            <button @click="stop">别浪</button>

        </div>
    </body>
    <script src="vue.js"></script>
    <script>
        var vm=new Vue({
            el:‘#app‘,
            data:{
                msg:‘猥琐发育,别浪~~~~‘,
                intervalId:null
            },
            methods:{
                lang() {
                    if(this.intervalId!=null) return;
                    this.intervalId=setInterval( () =>{
                        var start = this.msg.substring(0,1);
                        var end= this.msg.substring(1);
                        this.msg=end+start;
                    },400)
                    
                },stop(){
                    clearInterval(this.intervalId)
                    this.intervalId=null;
                }
            }})
    </script>

</html>

vue 跑马灯效果

原文:https://www.cnblogs.com/tiandlsd001/p/15242028.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!