art-template实战
内容div
<div id="sku-cont">
<div class="form-group col-lg-12">
<div class="col-lg-2">
</div>
<input type="hidden" name="sku_id[]"/>
<div class="col-lg-4">
<label class="control-label col-lg-3 text-right"><span class="control-label required-mark">*</span>规格:</label>
<input class="form-control-erbi col-lg-8 required sku" type="text" name="name[]" placeholder="如:土豪金,128G"/>
</div>
<div class="col-lg-4">
<label class="control-label col-lg-3 text-right"><span class="control-label required-mark">*</span>价格:</label>
<input class="form-control-erbi col-lg-6 required price" type="text" name="price[]" placeholder=""/>
</div>
</div>
</div>
模板
<!-- 模板 -->
<script id="sku-tpl" type="text/html">
{{ if data.is_new }}
<div class="form-group col-lg-12">
<div class="col-lg-2">
</div>
<input type="hidden" name="sku_id[]"/>
<div class="col-lg-4">
<label class="control-label col-lg-3 text-right"><span class="control-label required-mark">*</span>规格:</label>
<input class="form-control-erbi col-lg-8 required sku" type="text" name="name[]" placeholder="如:土豪金,128G"/>
</div>
<div class="col-lg-4">
<label class="control-label col-lg-3 text-right"><span class="control-label required-mark">*</span>价格:</label>
<input class="form-control-erbi col-lg-6 required price" type="text" name="price[]" />
</div>
<label class="control-label col-lg-1 del-btn">
<button type="button" class="btn btn-xs btn-danger del-sku" >删除</button>
</label>
</div>
{{ else }}
{{ each data.list }}
<div class="form-group col-lg-12">
<div class="col-lg-2">
</div>
<input type="hidden" name="sku_id[]" value="{{ $value.id }}"/>
<div class="col-lg-4">
<label class="control-label col-lg-3 text-right"><span class="control-label required-mark">*</span>规格:</label>
<input class="form-control-erbi col-lg-8 required sku" type="text" name="name[]" placeholder="如:土豪金,128G" value="{{ $value.name }}"/>
</div>
<div class="col-lg-4">
<label class="control-label col-lg-3 text-right"><span class="control-label required-mark">*</span>价格:</label>
<input class="form-control-erbi col-lg-6 required price" type="text" name="price[]" value="{{ $value.price }}"/>
</div>
{{ if $value.is_default == 0 }}
<label class="control-label col-lg-1 del-btn">
<button type="button" class="btn btn-xs btn-danger del-sku" >删除</button>
</label>
{{ /if }}
</div>
{{ /each }}
{{ /if }}
</script>
模板赋值
// 初始化
var in_data = '<?php echo json_encode($product_sku_list);?>';
in_data = JSON.parse(in_data);
if (in_data) {
let html = template('sku-tpl', {data:{is_new:false,list:in_data}});
$('#sku-cont').html(html);
// 添加移除事件
$(".del-sku").on("click",function() {
$(this).parent().parent().remove();
});
}
$("#make_sku_price").on("click",function() {
let html = template('sku-tpl', {data:{is_new:true}});
$('#sku-cont').append(html);
// 添加移除事件
$(".del-sku").on("click",function() {
$(this).parent().parent().remove();
});
});
注意语法前后空格。
很好用。
灵活巧妙运用,无限的可能。
art-template实战的更多相关文章
- art template前端模板引擎
偶然看到后台有一段代码 采用的是art template的模板引擎 地址为 http://aui.github.io/artTemplate/ 这段代码很简洁 var html = template( ...
- art.template 循环里面分组。
后台提供给我们一个数组,我们要用模版实现上面的格式输出怎么版呢? 下面就是解决方案: <h2>循环4个一组</h2> <script type="text/ht ...
- 利用art.template模仿VUE 一次渲染多个模版
TypeScript代码 import template = require('art-template/lib/template-web'); interface TemplateBindConfi ...
- 利用art.template模仿VUE
首先先看一下Typescript代码: import template = require('art-template/lib/template-web'); interface TemplateBi ...
- js 模板引擎 -Art Template
一个例子涵盖所有: <!doctype html> <html> <head> <meta charset="UTF-8"> < ...
- 一分钟上手artTemplate
一分钟上手artTemplate artTemplate是腾讯开源的前端模版引擎.之前做hue二次开发,只接触过用python写的mako模版引擎,所以之前对前端模版引擎了解不是很多. 这次因为pm叫 ...
- Express使用art-template模板引擎
第一步:安装 npm install --save art-template npm install --save express-art-template 第二步:指定.html使用的解析引擎(官方 ...
- vscode开发中绝对让你惊艳的插件!!!(个人在用)
识别模版引擎 1.Apache Velocity :识别Velocity(vm) 2.Art Template Helper:识别artTemplate 点击路径跳转 1.Laravel goto v ...
- ES6/ES2015的一些特性的简单使
1.一些常用的ES6的特性: let, const, class, extends, super, arrow functions, template string, destructuring, d ...
- artTemplate子模板include
art.Template:https://github.com/aui/art-template 下面来实现利用模版来实现递归调用生成tree <script type="text/h ...
随机推荐
- @Configuration与@Bean作用
Spring的Java配置方式是通过@Configuration和@Bean这两个注解来实现 @Configuration可以作用在任意类上,表示该类是一个配置类,其实就相当于一个xml配置文件. @ ...
- Docker MySQL5.5镜像
定制MySQL的镜像有个很大的难题:mysqld启动之前要初始化数据目录,5.5自带有空账号密码需要初始化. Dockerfile FROM centos # 拷贝需要的安装和MySQL初始脚本 CO ...
- Docker学习笔记之Docker 的简历
0x00 概述 在了解虚拟化和容器技术后,我们就更容易理解 Docker 的相关知识了.在这一小节中,我将介绍关于 Docker 的出现和发展,Docker 背后的技术.同时,我们将阐述 Docker ...
- php定界符<<<EOF讲解
Heredoc技术.可用来输出大段的html和javascript脚本 1.PHP定界符的作用就是按照原样,包括换行格式什么的,输出在其内部的东西: 2.在PHP定界符中的任何特殊字符都不需要转义: ...
- P2617 Dynamic Rankings(树状数组套主席树)
P2617 Dynamic Rankings 单点修改,区间查询第k大 当然是无脑树套树了~ 树状数组套主席树就好辣 #include<iostream> #include<cstd ...
- Deep Learning for NLP
Deep Learning for NLP The First Paper Proposed Bi-LSTM+CRF 我认为,第一篇提出 Bi-LSTM+CRF 架构的文章是: Huang Z, Xu ...
- 20145320周岐浩 web安全基础实践
20145320周岐浩 web安全基础实践 一.实验后回答问题 (1)SQL注入攻击原理,如何防御 一.SQL注入攻击原理 SQL注入攻击值得是通过构建特殊的输入作为参数传入web应用程序,而这些输入 ...
- QML手动连接信号槽【Connections】
1.使用Connections import QtQuick 2.6 import QtQuick.Window 2.2 import QtQuick.Controls 1.4 Window { vi ...
- ODAC(V9.5.15) 学习笔记(一)总论
一直在使用ODAC做开发,没时间仔细研究一下,目前采用的是3层结构,ODAC+TDataSetProvider+TClientDataSet做数据处理,也没有多大问题.下一步要开发B/S的程序了,打算 ...
- TFS 报错解决方案:tf400324
同事的解决方案没报这个问题将他的C:\Windows\System32\drivers\etc\hosts文件覆盖自己的文件,主要备份自己的文件不行了替换掉