vue中使用swiper
import Swiper from 'swiper';
methods: {
__init_swiper: function () {
let swiper = new Swiper('#swiper_container', {
autoplay: {
disableOnInteraction: false,
delay: 1000
},
pagination: {
el: '.swiper-pagination',
clickable: true
},
});
}
},
mounted: function () {
this.__init_swiper();
}
package.json中的确是有dom7的
我尝试着引入这个包,
import Dom7 from 'dom7';
import Swiper from 'swiper';
但没有任何效果,报的一样的错。
我知道可以在index.html中用<script>引入swiper,但现在我想只在这个component中引入。
could you please help me to solve this problem? or maybe there are any other way which can include the Swiper into the project? THANK Q.
不能单文件组件用的原因往往是没封装成Vue插件的形式,我觉得你可以考虑用这个 - vue-awesome-swiper