Vue.compile is not a function
See original GitHub issueI am using Vuejs 2 (webpack-simple template) and I would compile template before render it. Below my code : App.vue
<template>
<div id="app">
<h1>{{ msg }}</h1>
</div>
</template>
<script>
export default {
name: 'app'
}
</script>
main.js
import Vue from 'vue'
import App from './App.vue'
const res = Vue.compile(App)
const vm = new Vue({
el: '#app',
data: {
msg: 'hello'
},
render: res.render,
staticRenderFns: res.staticRenderFns
})
But when I start the server I got this error : __WEBPACK_IMPORTED_MODULE_0_vue___default.a.compile is not a function
. Can you please help me to make it work ?
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Vuejs, Universal app, compile is not a function - Stack Overflow
If I build the application as SPA (mode: 'spa'), it can works, but doesn't work for universal mode. I guess it's because the...
Read more >Vue.compile is not a function error when publishing ...
compile is not a function error when publishing component as a package. Hello, I've created the following simple component which i published on...
Read more >Vuejs, Universal app, compile is not a function - Get Help
I have vuejs application, build with nuxt cli. One vue component needs to load dynamic template, then compile on the fly.
Read more >vue compile render function from a template
In vuejs there is the vue compile global api method that can be used to compile a template string into an object that...
Read more >How to use the vue.compile function in vue - Snyk
it('should be able to bind scroll function', async () => { const res = Vue.compile('<div v-scroll="onScroll"></div>') const vm = new Vue({ data ()...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No. The whole point of vue files is to keep everything in one place. Why do you want an App.vue component if you only want the template string?
I don’t really understand what you are trying to do, or why, despite your explanation. Sorry 😦
Maybe save it as
.html
and install html-loader to dotemplate: require('html!./main.html')
import Vue from 'vue'
imports the runtime-only build, which does not have the compiler.https://vuejs.org/guide/installation.html#Standalone-vs-Runtime-only-Build
I will adjust the template to include the standalone build version by default.