使用colorui制作小程式滾動廣告欄
我們可以使用colorui組件開發小程式,能夠很容易的寫出廣告欄,
<template>
<view>
<view class="cu-bar margin-top">
<view class="action">
<text class="announce text-white">公告</text>
</view>
<view class="action">
<swiper :autoplay="true" :interval="3000" :duration="1000" vertical="true" circular="true" class="swiper-item">
<!-- 這里的vertical="true"是上下滾動,不設定則為左右 circular="true"表示的是回圈滾動,無縫連接-->
<swiper-item v-for="item in msg" class="swiper-item">
{{item}}
</swiper-item>
</swiper>
</view>
</view>
</view>
</template>
<script>
export default{
data(){
return {
msg:["廣告1廣告1廣告1廣告1廣告1廣告1廣告1","廣告2廣告2廣告2廣告2告2廣告2廣告2廣告2","廣告3廣告3廣告3廣告3廣告3廣告3廣告3","廣告4廣告4廣告4廣告4廣告4廣告4廣告4","廣告5廣告5廣告5廣告5廣告5廣告5廣告5","廣告6廣告6廣告6廣告6廣告6廣告6廣告6"],
}
}
}
</script>
<style>
.announce{
display: flex;
align-items: center;
justify-content: center;
width: 70rpx;
height: 50rpx;
border-radius: 15rpx;
background-color: #f26529;
transform: skewX(-20deg);
}
.swiper-item{
margin-left: 20rpx;
width: 600rpx;
height: 50rpx;
display: flex;
flex-wrap: nowrap;
align-items: center;
}
</style>

廣告中的內容就會自動播放,
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/277056.html
標籤:其他
