
div.test1(ref="test1") p.test(ref="test") 跑马灯,跑起来,嗨起来~~hello world 你好世界 世界你好哇
test () {
let boxWidth = this.$refs.test1.offsetWidth
let testWidth = this.$refs.test.scrollWidth
if (testWidth > boxWidth) {
this.testTimer = setInterval(() => {
if (this.$refs.test1.scrollLeft < testWidth - boxWidth) {
this.$refs.test1.scrollLeft++
} else {
clearInterval(this.testTimer)
this.$refs.test1.scrollLeft = 0
this.test()
}
}, 100)
}
},
.test1 {
color: #fff;
white-space: nowrap;
overflow: hidden;
width: 6rem;
background: #000;
}欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)