如果我在Google Chrome扩展程序中使用underscore.js的_.template(),我会在控制台中收到以下错误:
未捕获的错误:对于此上下文不允许从字符串生成代码
有没有办法克服这个错误?
我无法理解为什么this.model会在view.intialize()中定义,当我在它上面运行this.model.fetch()而不是在view.render()中.

define([
'jquery',
'underscore',
'backbone',
'text!templates/example.html'
], function($, _, Backbone, exampleTemplate){
var exampleView = Backbone.View.extend({
el: $('body'),
initialize: function() {
this.model.set({ _id: this.options.user_id });
this.model.fetch({
success: this.render,
error: function(model, response) {
console.log('ERROR FETCHING MODEL');
console.log(model);
console.log(response);
}
});
},
render: function() {
console.log('HELLO FROM RENDER');
console.log(this.model);
console.log('GOODBYE FROM RENDER');
}
});
return exampleView;
});
Run Code Online (Sandbox Code Playgroud)