1.自己写一个swiper组件,注意组件名最好不要用swiper,注意设置swiper的高度,因为他有默认,其实就和写小程序一样,不要慌。直接复制用就行了,要是你有接口,就改成v-for循环起来就可以了。
<template>
<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
<swiper-item>
<view class="swiper-item">
<image src="../../static/img/dy.jpg" mode=""></image>
</view>
</swiper-item>
<swiper-item>
<view class="swiper-item">
<image src="../../static/img/dy.jpg" mode=""></image>
</view>
</swiper-item>
</swiper>
</template>
<script>
</script>
<style>
swiper{
width: 100%;
height: 400rpx;
}
.swiper-item image{
width: 100%;
height: 400rpx;
}
</style>
2.注册组件并使用,哪里需要在哪里引入。就和vue中一样。
<template>
<view class="index">
<view class="f-active-color">
首页
<index-swiper&g