0

1x 代码:它正在工作。

this.$compile(this.$els.ajaxcontent);

2x 迁移:

this.$compile(this.$refs.ajaxcontent);
// Error: $compile function not found.

Vue.compile(this.$refs.ajaxcontent);
// Error: template.trim not a function.

Vue.compile($('#ajaxContent').get(0));
// Error: template.trim not a function.

编译文档:http: //vuejs.org/api/#Vue-compile

4

2 回答 2

1

解决方案:

var tmp = Vue.extend({ 
    template: 'Content'
})
new tmp().$mount(' id or refs ')
于 2016-10-17T09:37:40.367 回答
0

Vue.compile需要一个字符串。我不知道如何用 jquery 来做,但试试

Vue.compile(document.getElementById('ajaxContent').innerHTML)

于 2016-10-15T17:13:41.630 回答