3.0.5
Node 8.11.1
excuse
运行不了
报上面的错误
我用的vue-cli3, 没有vue.config.js 也没有 webpack配置文件,怎么弄呢?
请自行创建 vue.config.js 文件
What if you wanted the runtime compiler only for jest tests?
Use NODE_ENV to switch it
Use NODE_ENV to switch it or rewite the module path in jest config
Remap the module path in jest config
i had the same question , and resolved it ! change your webpack.config.js or App.vue like this :
resolve: {
alias: {
vue: 'vue/dist/vue.esm.js'
}
}
new Vue({
el: '#app',
router,
render: h => h(App)
})
TIps:
if you created your app by @vue/cli, please add code to your vue.config.js like this:
module.exports = {
runtimeCompiler: true,
}
that render: h => h(App)
thing was also what I was missing
that
render: h => h(App)
thing was also what I was missing
if pass in render: h => h(App)
, it ignores router. I am new to Vue but that is not the solution.
I am following the tutorials ,exact code. Blank page.
You have to pass the router to your Vue instanciation :
import Vue from 'vue'
import App from './App'
import store from './store'
import router from './router'
console.log('[i] Starting client app')
Vue.config.productionTip = false
new Vue({
render: h => h(App),
store,
router,
components: { App }
}).$mount('#app')
You have to pass the router to your Vue instanciation :
import Vue from 'vue' import App from './App' import store from './store' import router from './router' console.log('[i] Starting client app') Vue.config.productionTip = false new Vue({ render: h => h(App), store, router, components: { App } }).$mount('#app')
This solution work out for me. Thank you!
请自行创建 vue.config.js 文件
Fixed by this way.
the problem has been solved at https://github.com/vuejs-templates/webpack/issues/215
Simple way, change
import Vue from 'vue'
to
import Vue from 'vue/dist/vue.js';
It resolved my issue
I also encountered this problem when I converted the vue-cli 2.0 project into vue-cli 3.0.
I change
new Vue({
el: '#app',
router,
store,
components: {App},
template: '
})
to
new Vue({
render: h => h(App),
store,
router,
components: { App }
}).$mount('#app')
It resolved my issue
Hi everybody,
getting close to a solution:
so problem is related to syntax for vue 3.0 + ? Is it different than vue 2.0 ?
So could you please show a syntax that translate how to make use of multiple templates and components ?
e.g
import Vue from 'vue'
import App from './App.vue'
import Rating from './components/Rating'
new Vue({ el: '#app', template: '<Rating/>', components: { Rating }})
````
if I try:
new Vue({
render: h => h(App, Rating),
Rating,
template: '
components: { App, Rating}
}).$mount('#app')
```
I cannot see the rating component.
what is that
render: h => h(App),
and then mounted ?
I found former sytax more readable, espeically for more complex structures.
P..s.
could you help to pintpoint a tutorial that shows how to migrate to new syntax?
I created quite quickly a demo by putting everything in one index.html, including scripts and html. I would like to break down into templates and components, for the sake of maintanance, and attempting to use vue cli.
But feeling it consumes quite much of time to solve this hiccups.
Thank you for point at practical resources
I also add useful resource:
https://codewithhugo.com/writing-multiple-vue-components-in-a-single-file/
You have to pass the router to your Vue instanciation :
import Vue from 'vue' import App from './App' import store from './store' import router from './router' console.log('[i] Starting client app') Vue.config.productionTip = false new Vue({ render: h => h(App), store, router, components: { App } }).$mount('#app')
This solution work out for me. Thank you!
great! thank you
Why do I need a render
function within the root Vue instance?
The official vue-router
getting started example doesn't need one: https://jsfiddle.net/yyx990803/xgrjzsup/
Why doesn't vue-loader
transform my component within the route config?
For me, the solution was:
create a new file "vue.config.js" in the root folder and add
module.exports = {
runtimeCompiler: true
}
the problem has been solved at vuejs-templates/webpack#215
Simple way, change
import Vue from 'vue'
to
import Vue from 'vue/dist/vue.js';
It resolved my issue
This literally saved my day after over 3 hours of knocking my head! Thanks @db12138 .
i had the same question , and resolved it ! change your webpack.config.js or App.vue like this :
1. **webpack.config.js**
resolve: { alias: { vue: 'vue/dist/vue.esm.js' } }
1. **App.vue**
new Vue({ el: '#app', router, render: h => h(App) })
TIps:
if you created your app by @vue/cli, please add code to your vue.config.js like this:
module.exports = { runtimeCompiler: true, }
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
Or just add
new Vue({
store,
router,
render: (h) => {
return h();
},
}).$mount('#app');
For some reason the render function is required or it tries to compile an empty template and throws this warning, I think there should be a check if the template is empty as well to not throw this warning
And you can get rid of your App.vue file as well as the vue template compiler to reduce build size
On the vue.config.js file put:
module.exports = {
runtimeCompiler: true
}
Most helpful comment
i had the same question , and resolved it ! change your webpack.config.js or App.vue like this :
resolve: { alias: { vue: 'vue/dist/vue.esm.js' } }
new Vue({ el: '#app', router, render: h => h(App) })
TIps:
if you created your app by @vue/cli, please add code to your vue.config.js like this:
module.exports = { runtimeCompiler: true, }