I am currently using Vue JS and I am not using any router. I am not using stand-alone build and would like to implement with webpack and use it with .vue extension. Looking for better way to render a Vue template using a variable. For example :
// App.Vue
var Loading = {
template: `<div>Loading...</div>`
}
// main.js
var currentView = Loading;
new Vue({
el: "#app",
render(h) {
return h(currentView);
}
});
The above example perfectly works fine without any issues. Would like to understand if there is a better way to handle.
Let's say if currentView contains a string like
currentView = "Loading"
render(h) {
return h(eval(currentView)); // works
return h([currentView]); // template not found or mount error
}
How can we replace the value to the template before its passed to render function ?
Thanks in advance.