首页 > 其他 > 详细

vue使用Vant UI中的swiper组件及传值

时间:2019-12-16 13:55:59      阅读:1114      评论:0      收藏:0      [点我收藏+]

子组件SwiperBanner

<!--  -->
<template>
  <div class="swiper">
    <van-swipe :autoplay="3000"
               indicator-color="white">
      <van-swipe-item v-for="(item,index) in imgList"
                      :key="index">
        <img :src="item.img"
             alt=""
             title="" />
      </van-swipe-item>
    </van-swipe> 
  </div>
</template>

<script>
import Vue from vue;
import { Swipe, SwipeItem } from vant;
Vue.use(Swipe).use(SwipeItem);
export default {
  name: swiper,
  props: {
    imgList: {
      type: Array,
      required: true
    },
    aaa: ‘‘,
  },
  data () {
    return {
    };
  },
}
</script>
<style lang=scss  >
.swiper {
  width: 100%;
  height: 4rem;
  .van-swipe {
    height: 4rem;
    img {
      height: 100%;
      width: 100%;
    }
  }
}
</style>

父组件

<!--  -->
<template>
  <div class="goodsDetails">
    商品详情{{goodsId}}
    <SwiperBanner :imgList="imgList"
                  :aaa="aaa"></SwiperBanner>
  </div>
</template>

<script> 
import SwiperBanner from "@/components/SwiperBanner.vue"
export default {
  components: {
    SwiperBanner,
  },
  data () {
    return {
      goodsId: ‘‘,
      imgList: [
        { img: "https://img.yzcdn.cn/vant/apple-1.jpg" },
        { img: "http://file02.16sucai.com/d/file/2014/0704/e53c868ee9e8e7b28c424b56afe2066d.jpg" },
        { img: "https://img.yzcdn.cn/vant/apple-1.jpg" },
        { img: "http://file02.16sucai.com/d/file/2014/0704/e53c868ee9e8e7b28c424b56afe2066d.jpg" },
      ],
      aaa: wwwww
    };
  },
  mounted () {
    var that = this
    that.getGoodsId()
  },
  methods: {
    // 获取参数
    getGoodsId () {
      var that = this
      that.goodsId = this.$route.query.goodsId
    }
  },
}

</script>
<style lang=scss  >
</style>

vue使用Vant UI中的swiper组件及传值

原文:https://www.cnblogs.com/xiaoxiao2017/p/12048643.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!