答案 0 :(得分:0)
$.template('yourTemplateName', 'yourTemplateCode');
来自http://api.jquery.com/jQuery.template/
此方法将模板参数中的标记编译为命名模板,可以使用name参数中指定的字符串引用该模板。
返回值是编译模板函数。
示例:创建与名称“summaryTemplate”关联的编译模板,然后按名称引用它以进行渲染:
// Convert the markup string into a named template
$.template( "summaryTemplate", "<li>${Name}</li>" );
function renderList() {
// Render the movies data using the named template: "summaryTemplate"
$.tmpl( "summaryTemplate", movies ).appendTo( "#moviesList" );
}