广告
返回顶部
首页 > 资讯 > 前端开发 > JavaScript >uniapp vue与nvue轮播图之轮播图组件的示例代码
  • 712
分享到

uniapp vue与nvue轮播图之轮播图组件的示例代码

2024-04-02 19:04:59 712人浏览 安东尼
摘要

Vue部分如下: <template> <view class=""> <!-- 轮播图组件 --> <swiper :ind

Vue部分如下:


<template>
	<view class="">
		<!-- 轮播图组件 -->
		<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" circular="">
			<block v-for="(item,index) in swipers" :key="index">
				<swiper-item>
					<view class="swiper-item" @tap="event(index)">
						<image :src="item.src"
						 lazy-load
						 style="height: 350upx;"></image>
					</view>
				</swiper-item>
			</block>
		</swiper>
	</view>
</template>

nvue部分如下:


<template>
	<div>
		<!-- 轮播图组件 -->
		<slider :auto-play="true" :interval="3000" class="slider">
			<div style="position: relatice;" v-for="(item,index) in swipers" :key="index" @click="event(index)">
				<image class="image" resize="cover" :src="item.src"></image>
			</div>
			<indicator class="indicator"></indicator>
		</slider>
	</div>
</template>

nvue部分的CSS样式如下:


<style>
.slider,.image{
		width: 750px;
		height: 350px;
	}
	.indicator{
		position: absolute;
		right: 0;
		bottom: 0;
		width: 150px;
		height: 30px;
		background-color: rgba(0,0,0,0);
		item-color:rgba(255,255,255,0.5);
		item-selected-color: #FFFFFF;
	}
</style>

js部分如下:

vue与nvue的js写法是一样的


<script>
	export default {
		data() {
			return {
				swipers:[{src:"/static/images/demo/demo4.png"},
						{src:"/static/images/demo/demo4.png"},
						{src:"/static/images/demo/demo4.png"},
						{src:"/static/images/demo/demo4.png"}]
			}
		},
		methods: {
			event(index){
				console.log("点击了 index:"+index)
			}
		}
	}
</script>

效果图如下:

vue:

在这里插入图片描述

nvue:

在这里插入图片描述

到此这篇关于uniapp vue与nvue轮播图 轮播图组件的文章就介绍到这了,更多相关uniapp轮播图组件内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

--结束END--

本文标题: uniapp vue与nvue轮播图之轮播图组件的示例代码

本文链接: https://www.lsjlt.com/news/161181.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作