一个公告喇叭的组件

一个公告喇叭的组件

![在这里插入图片描述](https://img-blog.csdnimg.cn/20210324154511150.png
1.新建一个组件名为Notice的组件

<template>
	<view class="notice-content" :style="{background:backColor}">				//设置自定义的背景色
		<view class="notice-info flex-start">
		  <image src="../static/index/laba.gif" mode=""></image>				//喇叭的图片
	      <swiper :autoplay="true" :interval="3000" :duration="3000" class="swiper-notice" :circular="true" :previous-margin="20+'rpx'"  disable-touch="true" >			//disable-touch禁止拖动,如果不要可以不设置,previous-margin是跟前一个内容的距离,速度interval和duration可以自己设置想要的速度
	        <swiper-item v-for="(not,index10) in noticeList" :key="index10" @click="toUrl">
	          <view class="swiper-item">{{not}}</view>
        	</swiper-item>
     	  </swiper>
		</view>
	</view>
</template>
<script>
	export default {
    name:'Notice',
    props:{
      backColor:''
    },
		data() {
			return {
        noticeList:['恭喜王**通过参与活动抽奖获得二等奖88.88元','恭喜李**通过参与活动抽奖获得一等奖100.00元']
			};
		},
    methods:{
      toUrl(){
        uni.navigateTo({
          url:'/pages/talk/announcement_list'		//跳转到所有公告的页面
        })
      }
    }
	}
</script>

<style scoped>
  .flex-start{
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: wrap;
  }
  .notice-content{
    position: absolute;
    padding: 0 20rpx;
    background: #f2f2f2;
    left: 0;
    right: 0;
  }
  .notice-info{
    height: 60rpx;
    flex-wrap: nowrap;
  }
.notice-info>image{
  width: 30rpx;
  height: 30rpx;
  margin-right: 8rpx;
}

.swiper-notice{
  width: 90%;
  height: 60%;
}
</style>

这是喇叭的路径,需要的自己下载

2.引入组件
在需要的页面引入

import Notice from '../../components/Notice.vue';
export default {
 components: {
  	Notice
 },
 data(){
 	return{
		backColor: '#fff'
	}
 }
 }

引入完成后就可以使用了

<view class="news-content">
  <Notice :backColor="backColor"></Notice>
</view>

背景色可以自行设置

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值