报错!Cannot assign to read only property 'exports' of object

export default {
    data(){
        return {
            currentPage: 'findMusic',
            currentCut: 'discover',
        }
    },
    name: 'home',
    components: {
        headTop
    },
    mounted(){
         new Swiper('.swiper-container', {
            loop: true,
            autoplay: 3000,
            autoHeight: true,
            grabCursor: true,
            prevButton: '.swiper-button-prev',
            nextButton: '.swiper-button-next',
            pagination: '.swiper-pagination',
        });
    }
}
import '../plugins/swiper-3.4.2.min.js'
import '../styles/swiper.min.css'
<div class='swiper-container'>
            <div class='swiper-wrapper'>
                <div class='swiper-slide'><img src='../assets/slide/slide1.jpg'/></div>
                <div class='swiper-slide'><img src='../assets/slide/slide2.jpg'/></div>
                <div class='swiper-slide'><img src='../assets/slide/slide3.jpg'/></div>
                <div class='swiper-slide'><img src='../assets/slide/slide4.jpg'/></div>
                <div class='swiper-slide'><img src='../assets/slide/slide5.jpg'/></div>
                <div class='swiper-slide'><img src='../assets/slide/slide6.jpg'/></div>
            </div>
            <div class='swiper-pagination'></div>
            <div class='swiper-button-prev swiper-prev'></div>
            <div class='swiper-button-next swiper-next'></div>
        </div>

网上搜索,说的是 import 和 module.export不能混用,可是我这里没有混用啊。。。晕,哪位大佬能帮下,拜谢

阅读 14.5k
2 个回答

需要引入插件 babel-plugin-transform-es2015-modules-commonjs
然后在 .babelrc中配置 { "plugins": ["transform-es2015-modules-commonjs"] }

我的简书[https://www.jianshu.com/p/837...]

写法没有问题,我本地测试也没问题。
可能是 Swiper中最后这段导出的代码引起的 module.exports = window.Swiper

可以参考这篇文章解决下 GO

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏