这是我在weex里面写的,但是vue同样适用,只要把weex的text标签改成vue里面的基本标签
<template titile="模板页">
<ac-page
class="wrapper"
title="模板页"
headerMode="float"
bgColor=""
titleBgColor="transparent"
:scroll="false"
>
<div class="fixBox" ref="fixBox">
<div class="mesBox" :class="{marquee_top:animate}">
<div class="zhi" :id="animate?'main'+idx:''" v-for="(item, idx) in danmake" :key="idx">
<text class="text">{{ item }}</text>
</div>
</div>
</div>
</ac-page>
</template>
<script>
import PageMixin from '{BASE}/common/page-mixin';
import AcPage from '{BASE}/components/ac-page';
export default {
name: 'template',
mixins: [PageMixin],
data() {
return {
danmake: [
'1.滚动1',
'2.就得京东',
'3.对哦红豆味个还会觉得',
'4.你的哦ID哦个很好吃很纠结',
'5.记得',
],
animate:false,
showNum:4
}
},
components: {
AcPage
},
created() {
setInterval(this.scroll, 1500)
},
methods: {
scroll() {
this.animate=true
this.danmake.push(this.danmake[0])
let timer= setTimeout(()=>{
this.danmake.shift()
this.animate=false
clearTimeout(timer)
},800)
},
},
mounted(){
}
}
</script>
<style>
.wrapper {
flex: 1;
justify-content: center;
align-items: center;
}
.fixBox {
width: 500px;
height: 160px;
overflow: hidden;
position: relative;
overflow: hidden;
}
.mesBox {
position: absolute;
top: 0;
left:0;
}
.marquee_top {
transition: all 1s;
margin-top: -40px;
}
#main0{
transition: all 0.7s;
opacity: 0;
}
</style>