<wxs module="timer">
var time = function(value) {
var date = getDate(value);
var year = date.getFullYear()
var month = date.getMonth()+1
var day = date.getDate()
var hour = date.getHours()
var minute = date.getMinutes()
var second = date.getSeconds()
return [year,month,day].map(fn).join('-')+' '+[hour,minute,second].map(fn).join(':')
function fn(n) {
n = n.toString()
return n[1] ? n : '0' + n
}
}
module.exports = {
time: time
};
// module.exports.time= time;
</wxs>
{{timer.time(item.createTime)}}
-------------------------------------------------------
//wxs 文件
var format = function(value = 0, value1 = 0) {
return value * 1 + value1 * 1
};
var number = function(value) {
var num = value * 0.02586
return num.toFixed(2)
};
module.exports = {
format: format,
}
//引用
<wxs module="format" src="../../../utils/util.wxs"></wxs>
format.format ()
模板
<template name="msgItem">
<view>
<text> {{index}}: {{msg}} </text>
<text> Time: {{time}} </text>
</view>
</template>
<template is="msgItem" data="{{...item}}"/>
//------------------------------------------------------------------------------------
<template name="line">
<view class="case-line" bindtap="a">
<view>
<view class="line-head">血压监测报告
<text>2018-10-9 10:24:56</text>
</view>
<view class="line-description">内容备份内容备份内容内容备份内容备份内容内容备份内容备份内容内容备份内容备份内容内容备份内容备份内容</view>
</view>
<text class="iconfont icon-iconfontarrowright"></text>
</view>
</template>
应用
<!-- <import src ="/template/template.wxml"/> -->
<!-- <template is="line" ></template> -->