前言:html
概述以前先附上此正式版介绍地址:https://github.com/aui/artTemplate or http://www.jq22.com/jquery-info1097,能够再看下面文化在那个以前了解一下这俩个,若是以前你历来都没有接触过art-template。jquery
深刻了解:git
咱们用到最多的就是用thinkjs与art-template配合使用,而这二者怎么完美的配合在一块儿呢?github
1.首先:npm
执行命令,此为在项目中安装art-template模板:ui
npm install art-template --save
2.安装完毕后,再在项目中执行:this
thinkjs adapter template/dot
会在src/common/adapter/template/dot.js中建立一个dot.js文件,而在这里,须要将此文件中的内容稍微更改一下:spa
art-template.js的文件更改后的内容:3d
'use strict'; /** * base adapter */ import template from "art-template"; export default class extends think.adapter.base { /** * init * @return {[]} [] */ init(...args){ super.init(...args); } run(templateFile, tVar, config) { template.config('extname', ""); if (this.env != "production") { template.config("cache", false); } return template(templateFile, tVar); } }
3.改完以后,再将view.js中内容更改成:code
'use strict'; /** * template config */ export default { type: 'art-template', content_type: 'text/html', file_ext: '.html', file_depr: '_', root_path: think.ROOT_PATH + '/view', adapter: {} };
这样在前台页面展现的时候就能够用到后台模板渲染过来的数据,好比:
后记:
“好记性不如烂笔头”,这样但愿以后本身或者其余小伙伴们碰见相似的用法,方便使用。