解决javascript假值判断陷阱

位置:首页 / 技术中心 / 杂项

杂项 Admin 2026-05-25 17:36:31 182

当接口返回的dishType为number类型且为0,为了避免假值判断陷阱可使用以下方法


this.form.dishType = detail.dishType !== null && detail.dishType !== undefined ? Number(detail.dishType) : '';

18455111359 扫描二维码