Component({ properties: { /** 指标名称 */ title: { type: String, value: '', }, /** 指标数值(已格式化字符串) */ value: { type: String, value: null, }, /** 单位(元/次/人) */ unit: { type: String, value: '', }, /** 环比趋势 */ trend: { type: String, value: 'flat', // 'up' | 'down' | 'flat' }, /** 环比数值(如 "+12.5%") */ trendValue: { type: String, value: '', }, /** 帮助说明文字 */ helpText: { type: String, value: '', }, }, observers: { value(val: string | null | undefined) { // null/undefined 显示 "--" this.setData({ displayValue: val == null || val === '' ? '--' : val, }) }, }, data: { displayValue: '--', }, lifetimes: { attached() { const val = this.data.value this.setData({ displayValue: val == null || val === '' ? '--' : val, }) }, }, methods: { onTap() { this.triggerEvent('tap') }, onHelpTap(e: WechatMiniprogram.TouchEvent) { // 阻止冒泡到卡片 tap e.stopPropagation?.() this.triggerEvent('helpTap') }, }, })