如果在 index.html 文件中声明了我的应用程序模板,它们就可以工作。但是,我想将所有模板保存在不同的 html 文件中,例如 -AppTmpl.html
<!-- SidebarView Template -->
<script id="sideBarTmpl" type="text/template">
<div class="inner_div"><img src="images/com_logo.png"></div>
<div class="inner_div"><img src="images/adv_index.png"></div>
</script>
<!-- HeaderView Template -->
<script id="folderDivTmpl" type="text/template">
<div id="div_<%= menu_sequence %>"></div>
</script>
我正在使用下划线模板。但问题是这些模板不能通过下划线访问。比如,this.template = _.template($("#headerTmpl").html(), this.model.toJSON());
所以我需要做的就是在 index.html 或其他东西中包含“AppTmpl.html”文件。有什么解决办法吗?
提前致谢 !