Vue is not a constructor

天大地大妈咪最大 提交于 2020-12-01 09:10:33

问题


I using webpack, after build and run in chrome show this error,I don't know how to solve it.

My code is very simple:

{
  "devDependencies": {
    "babel-core": "^6.23.1",
    "babel-loader": "^6.3.2",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-es2015": "^6.22.0",
    "babel-runtime": "5",
    "css-loader": "^0.26.1",
    "html-webpack-plugin": "^2.28.0",
    "vue-hot-reload-api": "^2.0.9",
    "vue-html-loader": "^1.2.3",
    "vue-loader": "10.0.3",
    "vue-style-loader": "^2.0.0",
    "vue-template-compiler": "^2.1.10",
    "webpack": "^2.2.1",
    "webpack-dev-server": "^2.4.1"
  },
  "dependencies": {
    "vue": "^2.1.10"
  }
}

回答1:


Vue is the default export from that library so you import like this.

import Vue from 'vue'



回答2:


You need to import the runtime only build. This comment in the Github issues explains.

Put this in your webpack.config.js.

resolve: {
  alias: {
    vue: 'vue/dist/vue.js'
  }
}


来源:https://stackoverflow.com/questions/42343778/vue-is-not-a-constructor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!