无法正常使用computed的问题解决方案
发布于 3 年前 作者 fengtao 4104 次浏览 来自 分享
const computedBehavior = require('miniprogram-computed')

Component({
  behaviors: [computedBehavior.behavior],   // 关键在这里,官方文档上面写法不对
  properties: {
    data: {
      type: Object,
      value: {
        orderSource: '',
        orderStatus: -1
      }
    }
  },
  data: {},
  computed: {
    // 是否可以取消的逻辑判定
    isShowCancelBtn(data) {
      if (!data.data) {
        return false
      }
      const { orderSource, orderStatus, dtype, timeEnd } = data.data
      if (dtype === 6) {
        return false
      }
      if (orderStatus !== 1) {
        return false
      }
      if (dtype === 3) {
        return true
      }
      if (![9165].includes(orderSource) && timeEnd) {
        return true
      }
      return false
    },

  },
  
})

回到顶部