之前在做項(xiàng)目的時(shí)候 webpack 中使用swiper會(huì)出現(xiàn) error:Cannot assign to read only property 'exports' of object '#<Object>' 似乎是exports和import不兼容引起的
網(wǎng)上有很多解決辦法,但都不盡如人意。這里介紹一種比較好的兼容辦法
需要引入插件
-
npm install babel-plugin-transform-es2015-modules-commonjs
然后在 babelrc中配置
{ "plugins": ["transform-es2015-modules-commonjs"] }
即可解決