//const Foo = Vue.component('fool', { // template: '
foo {{count}}
', // data() { // return { // count: 123 // }; // }, // created: function () { // alert('created'); // } //}); const Foo = Vue.component('fool', function (resolve, reject) { // 可以请求一个html文件,既然存放模板还是html文件存放比较好 $.get("./test.c1.html").then(function (res) { resolve({ template: res, data() { return { count: 123 }; }, created: function () { alert('created'); } }) }); });