zoukankan      html  css  js  c++  java
  • Vue跑马灯

    跑马灯案例:

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    
        <title>Document</title>
    </head>
    
    <body>
        <div id="app">
            <input type="button" value="浪起来" @click="strat" :disabled="this.clearInt!=null">
            <input type="button" value="低调" @click="end" :disabled="this.clearInt==null">
            <div>{{data}}</div>
        </div>
    </body>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        var vm = new Vue({
            el: "#app",
            data: {
                data: "好好学习,天天向上,,,oooooo",
                clearInt: null,
                // dis: this.clearInt!=null
            },
            methods: {
                strat() {
                    clearInterval(this.clearInt)
                    this.clearInt = setInterval(() => {
                        // this.data = this.data.substr(1) + this.data.substr(0, 1)
                        // this.data = this.data.substring(1) + this.data.substring(0, 1)
                        this.data = this.data.slice(1) + this.data.slice(0, 1)
                    }, 300);
                },
                end() {
                    clearInterval(this.clearInt);
                    this.clearInt = null;
                }
            }
    
    
        })
    </script>
    
    </html>
  • 相关阅读:
    原生JS实现简易随机点名功能
    react 字父组件传值
    关于react组件传值问题
    轮波图
    烟花
    this的详解
    封装多元素多属性的链式缓冲
    留言板设计的流程,拖动窗口
    运动的小球
    运动的小球自动变键盘控制
  • 原文地址:https://www.cnblogs.com/bigbang66/p/13623637.html
Copyright © 2011-2022 走看看