<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vant@2.12.7/dist/vant.min.css" /> <script src="https://cdn.jsdelivr.net/npm/vue@2.6.12/dist/vue.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/vant@2.12.7/dist/vant.min.js"></script>
Vue.component('carousel', { template: ' <van-swipe :autoplay="true" :indicator-color="'blue'"> <van-swipe-item v-for="(item, index) in list" :key="index"> <img :src="item" alt="翻滚的胖子博客"> </van-swipe-item> </van-swipe> ', data() { return { list: ['https://example.com/image1.jpg', 'https://example.com/image2.jpg', 'https://example.com/image3.jpg'] } } })
new Vue({ el: '#app', template: ' <div id="app"> <carousel></carousel> </div> ' })
本文为翻滚的胖子原创文章,转载无需和我联系,但请注明来自猿教程iskeys.com