- TC.load("tmpl/tpl_list.html");
復(fù)制代碼首次訪問此函數(shù)時,會調(diào)用 tmpl/tpl_list.html 文件并緩存到 localStorage 中,以后會直接從 localStorage 中獲取 Template 的內(nèi)容,直到 TC.VERSION 中的值變化,才會重新調(diào)用文件。從而減少了主頁面請求的字節(jié)數(shù)。
用過 artTemplate 的人會習慣直接把一些內(nèi)容很短的模板直接寫在 JS 里,類似下面
- template.compile('header', '<div class="header"><h3><%= header.name %></h3></div>');
復(fù)制代碼當然這樣更省事。
此方案的是保證減少頁面請求字節(jié)及頁面請求數(shù)的目的下還能做到方便維護而提供的!
此功能在打通版微社區(qū)中實現(xiàn)!