art-template初用

使用方法:

1、引入模板引擎 ;

art-template初用

2、写模板;

art-template初用

3、映射数据

art-template初用

4、写入html数据

art-template初用

 

展示如下:

art-template初用整体代码展示如下:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <script src="../js/template-web.js"></script>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const student = {
            stuList: [
                {
                    name: '刘亦菲',
                    age: 18,
                    adrr: "纽约"
                },
                {
                    name: '杨紫',
                    age: 16,
                    adrr: "北京"
                }
            ]
        }
    </script>
    <script id="popList" type="text/html">
        {{each stuList as item}}
            <ul>
                <li> {{item.name}}</li> 
                <li> {{item.age}}</li> 
                <li> {{item.adrr}}</li> 
            </ul>
        {{/each}}
    </script>
    <script>
        window.onload = function () {
            const stuTemplate = template('popList', student);
            document.getElementById('content').innerHTML = stuTemplate;
        }
    </script>
    <div id="content"></div>
</body>
</html>

 存放模板引擎目录展示:

art-template初用

 

 

上一篇:【DIY活动】一起来做一个基于ART-Pi的多网卡 Demo


下一篇:node常用依赖混剪