1.根据后台返回的数据结构和数据类型做相应的处理
附图1⃣️
附图2⃣️
附图3⃣️
handleMbDetails(ids) {
this.$http.GET(mzTemplate.mbDetails, {
template_id: ids }).then(res => {
if (res.data && res.success) {
console.log(res)
//JSON.parse() 方法用于将一个 JSON 字符串转换为对象。附图1
const data = JSON.parse(res.data.template_str)
console.log(data)
const list = data.map(item => {
item.record_dose =
item.record_dose &&
//附图2
item.record_dose.substring(0, 1) === '0' &&
item.record_dose.indexOf('.') === -1
? ''
: item.record_dose
item.record_sudu =
item.record_sudu &&
item.record_sudu.substring(0, 1) === '0' &&
item.record_sudu.indexOf('.') === -1
? ''
: item