目录

Framework7 - Templates 概述

描述 (Description)

Template7是一个轻量级,移动优先的JavaScript引擎,它将Ajax和动态页面表示为具有指定上下文的Template7模板,不需要任何其他脚本。 Template7与Framework7相关联,作为默认的轻量级模板引擎,可以更快地为应用程序运行。

表现(Performance)

将字符串编译为JS函数的过程是template7的最慢段。 因此,您不需要多次编译模板,只需一次即可。

//Here initialize the app
var myApp = new Framework7();
// After initializing compile templates on app
var searchTemplate = $('script#search-template').html();
var compiledSearchTemplate = Template7.compile(searchTemplate);
var listTemplate = $('script#list-template').html();
var compiledListTemplate = Template7.compile(listTemplate);
// Execute the compiled templates with required context using onPageInit() method
myApp.onPageInit('search', function (page) {
   // Execute the compiled templates with required content
   var html = compiledSearchTemplate({/*...some data...*/});
   // Do stuff with html
});

Template7是一个轻量级模板引擎,用作没有Framework7的独立库。 可以使用两种方式安装Template7文件 -

  • 您可以从Template7 github存储库下载。

  • OR

  • 您可以使用以下命令通过Bower安装它 -

bower install template7
↑回到顶部↑
WIKI教程 @2018