html
<view class="bg_box icon_nav_box" style="margin-top: -70rpx;position: relative;">
<view class="flex flex_y_center">
<view class="c_red f32" style="font-style: italic;flex-shrink:0 ;">最新公告</view>
<view class="c_colum" style="line-height: 60rpx;height: 60rpx;overflow-y: hidden;position: relative;">
<view class="notice_main" style="top: {{notice_top}}rpx;">
<block wx:for="{{notice_list}}">
<view class="ml15 lineText">{{item.title}}</view>
</block>
</view>
</view>
</view>
</view>
.icon_nav_box .item{flex: 1;}
.icon_nav_box .icon{width: 100rpx;}
javascript
noticeScoll(){//公告滚动
let that = this;
let curindex = 0;
setInterval(() => {
let top = that.data.notice_top;
let notice_list = that.data.notice_list;
if(curindex < notice_list.length-1){
curindex = curindex+1;
that.setData({
notice_top: top - 60
})
}else{
curindex = 0;
that.setData({
notice_top: 0,
})
}
}, 3000);
},
data: {
notice_list:[
{title:"商城上线啦农资上线啦1",},
{title:"商城上线啦农资商城上线啦农资商城上线啦2",},
{title:"商城上线啦资商城上线啦农资商城上线啦3",},
{title:"商城上线啦啦农资商城上线啦4",},
{title:"商城上上线啦5",},
{title:"商城上线啦农啦农资商城上线啦6",},
],
notice_top:0,
},