简体   繁体   English

在骨干.js的视图中使用模板的问题

[英]Issue in using template in the view in backbone.js

I have a question related to backbone.js and I need your help. 我有一个与bone.js有关的问题,需要您的帮助。 I cannot understand the difference between: 我无法理解以下两者之间的区别:

currentCustomersTemplate : currentCustomersTemplate,
maincustomerTemplate : _.template(MainCustomerTemplate),

I mean the template with _. 我的意思是带有_.的模板_. and the one that does not have it! 还有一个没有它! Suppose I have a form (customer form) and inside this form I want to make (separate) forms related to each customer. 假设我有一个表单(客户表单),并且想要在此表单内创建(分离)与每个客户相关的表单。 So every time I add a customer by a button the information for each one goes to the currentCustomer form , which is "in" the main customerForm . 因此,每次我通过按钮添加一个客户时,每个客户的信息都会转到currentCustomer表单,该表单位于main customerForm (can be like multiple tables inside a bigger table). (就像一个更大的表中的多个表一样)。 So I have two templates. 所以我有两个模板。 Whats the difference of the first and second? 第一和第二有什么区别?

_.template () 'compiles' a raw template into a template object and you can provide different parameters for 'compiling'. _.template()将原始模板“编译”为模板对象,并且您可以提供不同的参数进行“编译”。 You can read underscore template doc in here for more details. 您可以在此处阅读下划线模板文档,以了解更多详细信息。

By following what you said, "currentCustomersTemplate" should have been already compiled before and it is a template object. 按照您所说的,“ currentCustomersTemplate”应该已经被编译过,并且它是一个模板对象。 You should see in somewhere prior being referred and there must be _.template() being called already. 您应该在被引用之前看到某个地方,并且必须已经有_.template()被调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM