アートテンプレートテンプレートエンジンの簡単な使い方

art-template は、最小限の超高速テンプレート エンジンです。スコープ事前宣言技術を使用してテンプレートのレンダリング速度を最適化し、JavaScript の限界に近い実行パフォーマンスを実現し、NodeJS とブラウザーを同時にサポートします。オンライン速度テスト。

1. ダウンロードアドレス

https://github.com/aui/art-template/releases

2. はじめに

<script src="模板引擎.js文件包地址"></script>

3. 使用する

https://aui.github.io/art-template/zh-cn/index.html

 $('#templateDemoBox').html(template('templateDemoBox_tmp', {
    
    
       list: res.data,
       imgUrl: window.api_config.imgUrl
       ......
}));
$('#templateDemoBox').on('click','.tapImg',function(e){
    
    
    console.log("我是图片我被点击了!")
});
<div id="templateDemoBox"></div>
    <script id="templateDemoBox_tmp" type="text/html">
    {
    
    {
    
    each list arr i}} 
    	{
    
    {
    
    if i==0}}
         	<img src="{
    
    {imgUrl}}{
    
    {arr.cover}}" class="tapImg"/>
         {
    
    {
    
    else if i==1}}
         	{
    
    {
    
    arr}}
         {
    
    {
    
    else}}
         	{
    
    {
    
    i}}
        {
    
    /if}} 
    {
    
    {
    
    /each}}
    </script>
</div>

おすすめ

転載: blog.csdn.net/weixin_49295874/article/details/130866926