微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

vue引入新版 vue-awesome-swiper插件填坑问题

本文介绍了关于新版 vue-awesome-swiper,分享给大家,具体如下:

问题

  1. 为什么我的vue-awesome-swiper组件pagination小圆点不显示问题?
  2. 为什么我的vue-awesome-swiper不会自动播放?
  3. 为什么我的vue-awesome-swiper没有?

使用

引入(前面的步骤和往常一样)

rush:bash;"> npm install vue-awesome-swiper --save

在 main,js 里引入(全局):

rush:js;"> import VueAwesomeSwiper from 'vue-awesome-swiper' Vue.use(VueAwesomeSwiper) import 'swiper/dist/css/swiper.css'

(css 不显示的问题可能就在这)

组件里引入:

rush:js;"> import 'swiper/dist/css/swiper.css' //在全局没引入,这里记得要! import { swiper,swiperSlide } from 'vue-awesome-swiper'

export default {
components: {
swiper,swiperSlide
}
}

配置

template:

rush:xhtml;"> I'm Slide 1 I'm Slide 2 I'm Slide 3

script:

rush:js;"> export default { data() { return { swiperOption: { // 所有的参数同 swiper 官方 api 参数一样 // } } },... }

重点在于 swiperOption 里面的变化,区别看下图:

原来 pagination 和 autoplay 要这样配置!

我原来就是在这两处错了,导致 pagination 不显示图片不轮播。

出错前:

纠正后:

imsun; white-space: normal; word-spacing: 0px; text-transform: none; float: none; font-weight: normal; color: rgb(0,0); font-style: normal; orphans: 2; widows: 2; display: inline !important; letter-spacing: normal; text-indent: 0px; font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px">

总结

vue-awesome-swiper官网其实早放出说明来了,但自己一看全是英文,就没想看下去。后来发其实很容易看懂得,吸取教训自己多去看看文档,不要找 demo 去抄。

还是少依靠插件,有些插件随时更新,等有能力,自己造!

弄到晚上12点,才弄明白原来 Swiper 版本区分了组件和普通版本,不能看照原来的经验写了。

发现网上关于最新 vue-awesome-swiper就两三篇,而且没说清楚。于是写下这篇,希望对大家有帮助,也希望大家多多支持编程之家

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐