鍍金池/ 問答/HTML/ npm install swiper后使用報(bào)錯(cuò)‘ Can't find vari

npm install swiper后使用報(bào)錯(cuò)‘ Can't find variable: Dom7’

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的
圖片描述

我嘗試著引入這個(gè)包,


    import Dom7 from 'dom7';
    import Swiper from 'swiper';

但沒有任何效果,報(bào)的一樣的錯(cuò)。

我知道可以在index.html中用<script>引入swiper,但現(xiàn)在我想只在這個(gè)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插件的形式,我覺得你可以考慮用這個(gè) - vue-awesome-swiper

2018年4月18日 05:05
編輯回答
憶當(dāng)年

有的是后就是包下的不完整 卸載之后再從新試一下 uninstall

2017年7月19日 00:31
編輯回答
陌如玉

樓主解決了嗎?

2017年7月3日 09:48