Browse Source

fix(cfc-frontend): 家庭挑战卡等待确认行末尾显示 undefined

FamilyChallengeCard.vue 模板引用 {{ deadlineText }},但 deadlineText 定义在 methods
中(方法),uni-app 编译产物 WXML 模板绑定无法解析方法,解析为 undefined 导致行尾
出现 "undefined"。将 deadlineText 移至 computed(无参数、仅依赖 this.challenge),
正确返回 剩余N天/已超时/截止今天/空,修复待确认行末尾 undefined。
Agnes Agent 1 week ago
parent
commit
bdaadd3348
1 changed files with 6 additions and 6 deletions
  1. 6 6
      cfc-frontend/components/FamilyChallengeCard.vue

+ 6 - 6
cfc-frontend/components/FamilyChallengeCard.vue

@@ -123,12 +123,6 @@ export default {
       if (target <= 0) return 0
       var p = Math.round(total / target * 100)
       return Math.min(p, 100)
-    }
-  },
-  methods: {
-    formatDate: function(dateStr) {
-      if (!dateStr) return ''
-      return String(dateStr).slice(0, 10)
     },
     deadlineText: function() {
       if (!this.challenge || !this.challenge.respondDeadline) return ''
@@ -139,6 +133,12 @@ export default {
       if (diffDays < 0) return '(已超时)'
       if (diffDays === 0) return '(截止今天)'
       return '(剩余 ' + diffDays + ' 天)'
+    }
+  },
+  methods: {
+    formatDate: function(dateStr) {
+      if (!dateStr) return ''
+      return String(dateStr).slice(0, 10)
     },
     memberPercent: function(value) {
       var target = this.challenge && this.challenge.targetValue ? this.challenge.targetValue : 1