耀极客论坛

 找回密码
 立即注册
查看: 707|回复: 0

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

[复制链接]

193

主题

-17

回帖

276

积分

中级会员

Rank: 3Rank: 3

积分
276
发表于 2022-5-7 01:05:26 | 显示全部楼层 |阅读模式
  这篇文章主要介绍了uniapp vue与nvue轮播图轮播图组件的实例代码,代码简单易懂,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
  vue部分如下:
  1. ‹template>
  2. ‹view class="">
  3. ‹!-- 轮播图组件 -->
  4. ‹swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" circular="">
  5. ‹block v-for="(item,index) in swipers" :key="index">
  6. ‹swiper-item>
  7. ‹view class="swiper-item" @tap="event(index)">
  8. ‹image :src="item.src"
  9. lazy-load
  10. >‹/image>
  11. ‹/view>
  12. ‹/swiper-item>
  13. ‹/block>
  14. ‹/swiper>
  15. ‹/view>
  16. ‹/template>
复制代码
  nvue部分如下:
  1. ‹template>
  2. ‹div>
  3. ‹!-- 轮播图组件 -->
  4. ‹slider :auto-play="true" :interval="3000" class="slider">
  5. ‹div v-for="(item,index) in swipers" :key="index" @click="event(index)">
  6. ‹image class="image" resize="cover" :src="item.src">‹/image>
  7. ‹/div>
  8. ‹indicator class="indicator">‹/indicator>
  9. ‹/slider>
  10. ‹/div>
  11. ‹/template>
复制代码
  nvue部分的css样式如下:
  1. ‹style>
  2. .slider,.image{
  3. width: 750px;
  4. height: 350px;
  5. }
  6. .indicator{
  7. position: absolute;
  8. right: 0;
  9. bottom: 0;
  10. width: 150px;
  11. height: 30px;
  12. background-color: rgba(0,0,0,0);
  13. item-color:rgba(255,255,255,0.5);
  14. item-selected-color: #FFFFFF;
  15. }
  16. ‹/style>
复制代码
  js部分如下:
  1. vue与nvue的js写法是一样的
复制代码
  1. ‹script>
  2. export default {
  3. data() {
  4. return {
  5. swipers:[{src:"/static/images/demo/demo4.png"},
  6. {src:"/static/images/demo/demo4.png"},
  7. {src:"/static/images/demo/demo4.png"},
  8. {src:"/static/images/demo/demo4.png"}]
  9. }
  10. },
  11. methods: {
  12. event(index){
  13. console.log("点击了 index:"+index)
  14. }
  15. }
  16. }
  17. ‹/script>
复制代码
  效果图如下:
  vue:

  nvue:

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


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|耀极客论坛 ( 粤ICP备2022052845号-2 )|网站地图

GMT+8, 2023-3-24 15:10 , Processed in 0.072717 second(s), 20 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表