Vue and dynamic run-time compiled templates
Posted on February 9, 2020
If you want to allow a Vue app compiles at run-time a given Vue template and you get this issue:
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.
after trying something like:
<template>
<div id="app">
<component :is="mysrc"></component>
</div>
</template>
<script>
export default {
data(){
return{
mysrc:{
template:`<div>{{Math.random()}}</div>`
}
}
}
}
</script>
Here the solution, thanks to this article, to be put in vue.config.js
:
module.exports = {
runtimeCompiler: true
}