// component/faultItem/faultItem.ts import { TimeUtil } from '../../utils/TimeUtil' Component({ /** * 组件的属性列表 */ properties: { //0=待维修 1=维修中 2=已完成 faultStatus: { type: Number, value: 0 }, faultRepairNo: { type: String, value: '' }, faultReportTime: { type: String, value: '' }, faultProvinceCity: { type: String, value: '' }, faultSchoolName: { type: String, value: '' }, faultClassName: { type: String, value: '' } }, /** * 组件的初始数据 */ data: { status: 0, statusText: "", faultTime: '', }, lifetimes: { attached: function () { // 在组件实例被从页面节点树添加时执行 let text = ""; switch (Number(this.properties.faultStatus)) { case 0: text = "待维修"; break; case 1: text = "维修中"; break; case 2: text = "已完成"; break; } this.setData({ status: this.properties.faultStatus, statusText: text, faultTime: TimeUtil.dateFormat(parseInt(this.properties.faultReportTime), "yyyy-MM-dd HH:mm") }) console.log("status:", this.data.status) console.log("propertiesstatus:", this.properties.faultStatus) }, detached: function () { // 在组件实例被从页面节点树移除时执行 }, }, /** * 组件的方法列表 */ methods: { } })