order_price() {
let fee = this.orderinfo?.total_price ?? 0;
let money = this.coupon?.money ?? 0
return (Number(fee) - Number(money)).toFixed(2)
}

7***@qq.com
- 发布:2023-10-11 09:34
- 更新:2023-10-11 16:42
- 阅读:290
w***@163.com
?? 0:最后,使用空值合并操作符 (??) 来处理可能的 undefined 或 null 值。如果 fee 或 money 的值为 undefined 或 null,那么它们将被赋值为 0。这确保了即使 total_price 和 money 不存在或为空,fee 和 money 也将有默认值 0。
2023-10-11 16:42