webpack使用art-template

下载
npm i art-template-loader art-template -d
配置
module.exports = {
    module: {
        rules: [
            {
                test: /\.art$/,
                loader: 'art-template-loader'
            }
        ]
    }
 }
使用

1、定义模板
template/header.art

<h1>{{title}}</h1>

template/index.art

{{include './header.art'}}

<p>{{msg1}}</p>
<p>{{msg2}}</p>

2、渲染地址
index.html

<div id="app"></div>

3、渲染
main.js

//获取模板
const render = require('./templates/index.art');
//配置数据
const data = {
    title: '这是art-template页面',
    msg1: '信息一',
    msg2: '信息二'
};
//数据渲染
const html = render(data);
//渲染到页面
const app = document.getElementById('app');
app.innerHTML = html;
完成

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值