SOURCE

console 命令行工具 X clear

                    
>
console
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>vue.js文字公告自动滚动切换代码</title>

<style>

.marquee {
	width: 100%;
	height: 50px;
	align-items: center;
	/* color: #3A3A3A; */
	background-color: #b3effe;
	display: flex;
	/* box-sizing: border-box; */
}

.marquee_title {
	padding: 0 20px;
	height: 30px;
	font-size: 14px;
	border-right: 1px solid #d8d8d8;
	align-items: center;
    background-color:red;
}

.marquee_box {
	width: 80%;
	height: 30px;
	overflow: hidden;
    background-color:purple;
}

.marquee_list {
	/* display: block; */
}
.marquee_top {
	transition: all 0.5s;
	margin-top: -30px
}

.marquee_list div {
    width:100%;
	height: 30px;
	line-height: 30px;
	font-size: 14px;
	padding-left: 20px;
    background-color:green;
}

/* .marquee_list div span {
	padding: 0 2px;
    background-color:yellow;
} */

.red {
	color: #FF0101;
}

</style>

</head>
<body><script src="/demos/googlegg.js"></script>

<div class="vueBox">
    <div class="marquee">
       
        <div class="marquee_box">
            <div class="marquee_list" :class="{marquee_top:animate}">
                <div v-for="(item, index) in marqueeList">
                    <span>{{item.name}}</span>
                    <span>已抽中</span>
                    <span class="red"> {{item.city}}</span>
                </div>
            </div>
        </div>

    </div>
    
      <p>jkdsjfkdldf </p>
</div>
<script type="text/javascript">
    const vm = new Vue({
        el: ".vueBox",
        data: {
            animate: false,
            marqueeList: [
                {
                    name: '小明',
                    city: '2000乐币',
                    amount: '10'
                },
                {
                    name: '彩虹',
                    city: '鲜花x999',
                    amount: '20'
                },
                {
                    name: '雷电',
                    city: '1万朵鲜花',
                    amount: '30'
                },
                {
                    name: '小太阳',
                    city: '拜年啦道具拜年啦道具',
                    amount: '40'
                }
            ]
        },
        created: function () {
            setInterval(this.showMarquee, 2000)
        },
        methods: {
            showMarquee: function () {
                this.animate = true;
                setTimeout(()=>{
                    this.marqueeList.push(this.marqueeList[0]);
                    this.marqueeList.shift();
                    this.animate = false;
            },300)},
        }
    });
</script>

</body>
</html>

本项目引用的自定义外部资源