thinkjs——art-template模板用法
前言:
概述之前先附上此正式版介绍地址:https://github.com/aui/artTemplate or http://www.jq22.com/jquery-info1097,可以再看下面文化在那个之前了解一下这俩个,如果之前你从来都没有接触过art-template。
深入了解:
我们用到最多的就是用thinkjs与art-template配合使用,而这两者怎么完美的配合在一起呢?
1.首先:

执行命令,此为在项目中安装art-template模板:
npm install art-template --save
2.安装完毕后,再在项目中执行:

thinkjs adapter template/dot
会在src/common/adapter/template/dot.js中创建一个dot.js文件,而在这里,需要将此文件中的内容稍微更改一下:

art-template.js的文件更改后的内容:
'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中内容更改为:
'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: {}
};
这样在前台页面展示的时候就可以用到后台模板渲染过来的数据,比如:

后记:
“好记性不如烂笔头”,这样希望之后自己或者其他小伙伴们遇见类似的用法,方便使用。
thinkjs——art-template模板用法的更多相关文章
- art template前端模板引擎
偶然看到后台有一段代码 采用的是art template的模板引擎 地址为 http://aui.github.io/artTemplate/ 这段代码很简洁 var html = template( ...
- kendo ui template的用法
kendo ui template的用法: Kendo UI 框架提供了一个易用,高性能的JavaScript模板引擎.通过模板可以创建一个HTML片段然后可以和JavaScript数据合并成最终的H ...
- 小程序开发--template模板
小程序的template模板可以说是我遇到的最简单的了,看看实例: <template name="article"> <view class='containe ...
- django基础2: 路由配置系统,URLconf的正则字符串参数,命名空间模式,View(视图),Request对象,Response对象,JsonResponse对象,Template模板系统
Django基础二 request request这个参数1. 封装了所有跟请求相关的数据,是一个对象 2. 目前我们学过1. request.method GET,POST ...2. reques ...
- angularjs指令系统系列课程(2):优先级priority,模板template,模板页templateUrl
今天我们先对 priority,template,templateUrl进行学习 1.priority 可取值:int 作用:优先级 一般priority默认为0,数值越大,优先级越高.当一个dom元 ...
- ArcGIS API for Silverlight代码中使用Template模板
原文:ArcGIS API for Silverlight代码中使用Template模板 在项目开发中,会遇到点选中聚焦闪烁效果,但是因为在使用Symbol的时候,会设置一定的OffSetX和OffS ...
- Git commit template 模板设定
多人协作开发一个项目时,版本控制工具是少不了的,git是linux 内核开发时引入的一个优秀代码管理工具,利用它能很好使团队协作完成一个项目.为了规范团队的代码提交,也方便出版本时的release n ...
- 一个简单地template模板
之前的项目中用到了artTemplate模板,感觉挺有意思,于是查看相关资料,自己动手写了个简单地template模板插件.虽然会有一些不足,但也是自己的一番心血.主体代码如下 /* * 一个简单地t ...
- Vue 组件&组件之间的通信 之 template模板引用与动态组件的使用
template模板引用 在component的template中书写大量的HTML元素很麻烦. Vue提供了<template>标签,可以在里边书写HTML,然后通过ID指定到组建内的t ...
随机推荐
- JAVA-JSP注释
相关资料: <21天学通Java Web开发> 结果总结: 1.一类可以在客户端显示的注释,即HTML注释.2.<!-- -->,中间为注释部分.3.如果使用MyEclipse ...
- ativemq使用教程
本文转自http://www.cnblogs.com/zhuxiaojie/p/5564187.html 目录: 一:JMQ的两种消息模式 1.1:点对点的消息模式 1.2:订阅模式 二:点对点的实 ...
- winform文本框不能粘贴、复制和屏蔽右键
有3个常用方法 1.MouseMove事件中,使选不中 private void textBox3_MouseMove(object sender, MouseEventArgs e) { if (t ...
- 在XP系统下如何访问win10共享的打印机
< > 找到 GUEST 用户,添加即可. 2. Win10 共享本地打印机 右击要共享的打印机,共享选项卡,设置共享名,这个共享很重要,要记住,尽量设置简单点.IP + 共享名就是网络打 ...
- javascript 鼠标方式去显示
document.write("<style type='text/css'>"); document.write(".yyfloat_p{width:209 ...
- C# 关于JArray和JObject封装JSON对象
直入主题,不废话... 1.JObject:基本的json对象 /// <summary> /// Gets the j object. /// </summary> /// ...
- Hibernate 注解中CascadeType用法汇总
这两天,参加一个课程设计,同时这个项目又作为一个模块镶嵌到其他项目中,考虑如此,应与原先的架构相同,因牵扯到留言和相互@功能,故数据库之间OneToOne,OneToMany,ManyToMany之风 ...
- am335x mux配置
/**************************************************************** * am335x mux配置 * * am335x的引脚复寄存器是C ...
- The configuration file 'appsettings.json' was not found and is not optional
问: .Net Core: Application startup exception: System.IO.FileNotFoundException: The configuration file ...
- php -- 取日期
1.获取当前时间方法date()很简单,这就是获取时间的方法, 格式为:date($format, $timestamp), format为格式 - 必需 timestamp为时间戳–可填参数. 比如 ...