Vue中怎样使用swiper组件?
2019-06-12 09:09
288 查看
版权声明:xue_shuai https://blog.csdn.net/qq_41980461/article/details/91489105
我用的VS Code编译器,首先打开终端,进入项目(我是在13-vue文件夹下面的elem中使用)
[code]D:\study\web\13-vue\elem> cnpm install vue-awesome-swiper --save
然后在main.js中引用并使用
[code]import VueAwesomeSwiper from 'vue-awesome-swiper' import 'swiper/dist/css/swiper.css' Vue.use(VueAwesomeSwiper)
新建一个swiper组件,里面内容如下
[code]<template> <div class="swiper"> <swiper :options="swiperOption" class="swiper-menu"> <!-- slides 列表项 --> <swiper-slide>I'm Slide 1</swiper-slide> <swiper-slide>I'm Slide 2</swiper-slide> <!-- Optional controls 控制器 --> <div class="swiper-scrollbar" slot="scrollbar"></div> </swiper> </div> </template> <script> export default { name: 'WaimaiSwiper', data () { return { swiperOption: { loop: true// 是否循环轮播 } } } } </script> <style lang="stylus" scoped> </style>
在父组件中使用该swiper组件
[code]<template> <div> <waimai-swiper></waimai-swiper> </div> </template> <script> import WaimaiSwiper from './components/swiper' export default { name: 'Waimai', data () { return { } }, components: { WaimaiSwiper } } </script>
效果如图所示
若需要其他样式的swiper组件,详情参考Swiper中国
相关文章推荐
- vue2.0使用swiper组件实现轮播效果
- vue2.0使用swiper组件实现轮播
- vue2.0使用swiper组件实现轮播的示例代码
- vue-13-swiper组件的使用
- vue-awesome-swiper滑块插件使用方法详解
- 在vue-cli的组件模板里使用font-awesome
- Vue.js父与子组件之间传参 父向子组件传参 例子:App.vue为父,引入componetA组件之后,则可以在template中使用标签(注意驼峰写法要改成componet-a写法,因为ht
- 使用vue与element组件
- 解决vue中使用swiper插件——李帅醒博客
- vue.js基本使用 父子组件<三>
- vue组件中使用iframe元素的示例代码
- vue-swiper的使用教程
- Vue.js 中使用PubSub.js 进行同级组件间通信
- 在vue中使用wangEditor富文本编辑器组件的形式
- 使用vue开发web app - 1 - 初步使用vue创建组件
- vue组件中的.sync修饰符使用
- 使用FileReader API创建Vue文件阅读器组件
- Vue 自定义组件使用v-model
- Vue.js之组件data的使用
- Vue.js分页组件实现:diVuePagination的使用详解