Loading... 今天做一个 列表循环的时候,有一个值是 unix 的时间,所以需要格式化 时间 就去找了下资料,可以通过 filter 来替换值 直接代码吧 ```js <template> <view class="" v-for="(item,index) in jokes" :key="index"> <view class="margin-top"> <uni-card :title="item.title" :note="item.unixtime|dateFormat"><!-- 值的后面 加上过滤器 --> <text selectable="true" @click="copyData" :data-con="item.content">{{item.content}}</text> </uni-card> </view> </view> </template> <script> export default{ data(){ return { jokes:[] } }, //定义过滤器 filters:{ dateFormat(value){ return utils.timeTodate('Y-m-d H:i',value*1000) } } } </script> ``` Last modification:October 21st, 2019 at 08:11 pm © 允许规范转载 Support 如果觉得我的文章对你有用,请随意赞赏 ×Close Appreciate the author Sweeping payments Pay by AliPay Pay by WeChat