微信小程序框架wxml(四)wxml模板
来源:互联网 发布:看电视用什么软件 编辑:程序博客网 时间:2024/04/19 05:03
1.首先在wxml中定义template的样式
<template name="msgItem"> <view> <text> {{index}}: {{msg}} </text> <text> Time: {{time}} </text> </view></template>2.在js中写入几组数据
// pages/wxml2/wxml2.jsPage({ data: { item1: { index: 0, msg: 'this is the first template', time: '2016-09-15' },item2: { index: 1, msg: 'this is the second template', time: '2016-09-30' }, item3: { index: 2, msg: 'this is the third template', time: '2016-10-09' } }})3.在wxml中使用template模板
<template is="msgItem" data="{{...item1}}"/><template is="msgItem" data="{{...item2}}"/><template is="msgItem" data="{{...item3}}"/>4.效果图
此外,template支持Mustache语句
<block wx:for="{{[1, 2, 3, 4, 5]}}"> <text>{{item}}</text> <template is="{{item % 2 == 0 ? 'even' : 'odd'}}"/></block>效果图↓
阅读全文
0 0
- 微信小程序框架wxml(四)wxml模板
- 微信小程序框架wxml(一)wxml数据绑定
- 微信小程序框架wxml(二)wxml列表渲染
- 微信小程序框架wxml(三)wxml条件渲染
- 微信小程序框架wxml(五)wxml事件
- 微信小程序框架wxml(六)wxml引用
- 微信小程序 四 wxss引用 wxml引用
- 小程序WXML之模板
- 1.3.1微信小程序 WXML
- 微信小程序的学习(3)-视图层WXML
- 微信小程序-订单评价交互样式(WXML&WXSS&JS)
- 微信小程序WXML之列表渲染
- 微信小程序wxml和wxss样式
- 微信小程序 Html转Json转Wxml
- 微信小程序:wxml组件整理,待补充......
- 微信小程序WXML之列表渲染
- 微信小程序-wxml和wxss样式
- 微信小程序WXML 数据绑定、列表渲染、条件渲染、模板、事件、引用用法
- 洛谷P2061 [USACO07OPEN]城市的地平线City Horizon
- Linux Android bashrc 配置
- linux:进程创建及父子间使用pipe通信
- [NOI2002]Sevege 扩展欧几里得
- opencv学习——cv2.imshow()显示图片
- 微信小程序框架wxml(四)wxml模板
- 一个项目:SSM的配置文件
- 关于二叉树的几种遍历方法
- Java五道输出易错题解析(避免小错误)
- 通过runtime 交换webView的url
- (学习java)顺序栈的实现以及二进制的转换
- 多变量条件概率等价式推导
- 信号强度解释和计算
- Maven打包war和ear