airyland / vux

Mobile UI Components based on Vue & WeUI
https://vux.li
MIT License
17.59k stars 3.71k forks source link

[Bug Report] 初始化引入后,vux/src/libs/passive_supported.js文件exports.default报错 Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>' #3441

Closed Little-Little-Monster closed 5 years ago

Little-Little-Monster commented 5 years ago

VUX version

2.9.2

OS/Browsers version

window/google73.0.3683.86

Vue version

2.6.6

Code

//main.js
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './assets/css/index.scss'
import './VuxConfig'
Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

//vue.config.js
 configureWebpack: config => {
    vuxLoader.merge(config, {
      plugins: ['vux-ui', 'duplicate-style']
    })
  }

//VuxConfig.js
import Vue from 'vue'
import {
  AlertPlugin,
  ToastPlugin,
  AjaxPlugin,
  TransferDom,
  Flexbox,
  FlexboxItem,
  XHeader,
  viewBox,
  Tabbar,
  TabbarItem
} from 'vux'
import FastClick from 'fastclick'
import store from './store'
import router from './router'

Vue.directive('transfer-dom', TransferDom)

Vue.use(AlertPlugin)
Vue.use(ToastPlugin)
Vue.use(AjaxPlugin)

Vue.component('flexbox', Flexbox)
Vue.component('flexbox-item', FlexboxItem)
Vue.component('x-header', XHeader)
Vue.component('x-header', XHeader)
Vue.component('view-box', viewBox)
Vue.component('view-box', viewBox)
Vue.component('tabbar', Tabbar)
Vue.component('tabbar-item', TabbarItem)
// 点击延迟
FastClick.attach(document.body)

// 页面切换loading
store.registerModule('vux', { // 名字自己定义
  state: {
    isLoading: false
  },
  mutations: {
    updateLoadingStatus (state, payload) {
      state.isLoading = payload.isLoading
    }
  }
})
router.beforeEach(function (to, from, next) {
  store.commit('updateLoadingStatus', { isLoading: true })
  next()
})

router.afterEach(function (to) {
  store.commit('updateLoadingStatus', { isLoading: false })
})

Steps to reproduce

报错提示的是 在webpack打包的时候,可以在js文件中混用require和export。但是不能混用import 以及module.exports。 因为webpack 2中不允许混用import和module.exports,

vue-cli3 通过vue/cli-plugin-vux插件引入vux项目,是还需要配置什么吗?

What is Expected?

正常运行

What is actually happening?

抛出异常

iamziyue commented 5 years ago

这个问题遇到好几次了,这次升级后又得改,这个文件:node_modules\vux\src\libs\passive_supported.js,改为:

// module.exports = passiveSupported
export default passiveSupported
Little-Little-Monster commented 5 years ago

这个问题遇到好几次了,这次升级后又得改,这个文件:node_modules\vux\src\libs\passive_supported.js,改为:

// module.exports = passiveSupported
export default passiveSupported

那请问目前哪个版本是正常的呢?之前我就回退到2.8.0也报这个错

Little-Little-Monster commented 5 years ago

这个问题遇到好几次了,这次升级后又得改,这个文件:node_modules\vux\src\libs\passive_supported.js,改为:

// module.exports = passiveSupported
export default passiveSupported

刚刚试了一下,直接改完那个文件后,会发现其他文件也有这个错,不止一个文件。是我配置有问题吗?

iamziyue commented 5 years ago

@Little-Little-Monster 我也是刚刚遇到这个问题,目前就改了这一处,要不你都改了试试。

Little-Little-Monster commented 5 years ago

@Little-Little-Monster 我也是刚刚遇到这个问题,目前就改了这一处,要不你都改了试试。

改不完,改了两个,又出来一个相关的。我还是用vue-cli2.0吧 之前有人提过这个issue,和新版本webpack有些地方不兼容,module.exports好多地方没统一

airyland commented 5 years ago

已经都改了,这两天发布个新版本。

Little-Little-Monster commented 5 years ago

已经都改了,这两天发布个新版本。

好的 辛苦了

airyland commented 5 years ago

已经发布,还有问题请反馈我及时解决。