Vue is introducing vue files so dynamically?

  javascript, question

I need to introduce a new vue file when the vue project is running. The file is generated by the server and returned via ajax request. How do I realize this function?


That. . I just noticed the. vue document. . Vue files are not very feasible, because the vue files themselves are compiled after being processed by webpack such as vue-loader. otherwise, problems including templates, styles, es6 syntax, etc. cannot be identified. However, if the vue instance can be written by the following method, the template can be written by the render function and then dynamically mounted, then there should be no problem.

Update again. . .

Just now I read the introduction of vue website. runtime and Compiler can realize direct html of templates without using render. The host can study it.
Vue compiler
In theory, it can be realized. Please refer to vue website api.Vue.extend introduction
I wrote demo

 <script src=""></script>
 <div id="app">
 <p>{{ message }}</p>
 <input type="text" v-model="message"/>
 < button @click="dynamicMount "> dynamically mount vue</button >
 <div id="mount-point">
 new Vue({
 el: '#app',
 data: {
 message:'Hello World!'
 created() {
 this.dynamicMount = function() {
 let Profile = Vue.extend({
 template: '<p>{{firstName}} {{lastName}} aka {{alias}}</p>',
 data: function () {
 return {
 firstName: 'Walter',
 lastName: 'White',
 alias: 'Heisenberg'
 //Create a Profile instance and mount it on an element.
 new Profile().$mount('#mount-point')