You are using the runtime-only build of vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.
创建 vu-cli, 运行项目正常, 我新建的项目 main.js 配置实例的时候是
render:h=>h(App)
如果我改成下面这样
- template:'<App />',
- components:{
- App
- },
- import Vue from "vue"
- import VueRouter from "vue-router"
- import App from "./App"
- import home from "./components/home"
- Vue.use(VueRouter)
- const router = new VueRouter({
- routes:[
- {
- path:"/",
- component:home
- }
- ]
- })
- new Vue({
- el: "#app",
- template:'<App />',
- components:{
- App
- },
- // render: h => h(App)
- })
import Vue from "vue" 这一行引用不对, 去 node_model 中找到 vue 的 package.json, 找到里面的 main, 发现后面引入的并不是 vue.js
就去网上找了一下这个错误的修复方法, 具体解决办法如下:
- resolve: {
- extensions: ['.js', '.vue', '.json'],
- alias: {
- '@': resolve('src'),
- 'vue':'vue/dist/vue.js'
- }
- },
'vue':'vue/dist/vue.js'就是在 webpack.base.config.js 中找到这里, 这句话意思是重新配置下路径名字, 添加上这句就好了!
来源: http://www.qdfuns.com/article/17606/b2e1f5873bc4e9f291af9d551ad40a5a.html