按照了他的方式給值後輸出
let lunar = this.converter.SolarToLunar(this.solar)
發現在執行 this.converter.SolarToLunar(this.solar)
時會出現錯誤
You may have an infinite update loop in a component render function.
以下是我的 code
let data = JSON.parse(row);
let keys = ``
Object.values(data).forEach(ele => {
keys = Object.values(ele)[0]
})
console.log(keys)
if (keys.includes('-'))
keys = this.handleBirth(keys)
return keys
會拿到
2010-05-09 10
1997-08-20 01
2012-06-09 10
handleBirth func
let before = keys.substr(0, 10)
let birth = before.split('-')
this.solar.solarYear = Number(birth[0])
this.solar.solarMonth = Number(birth[1])
this.solar.solarDay = Number(birth[2])
let lunar = this.converter.SolarToLunar(this.solar)
return `農曆:${lunar.lunarYear}-${lunar.lunarMonth}-${lunar.lunarDay}`
進入handleBirth前就只有三個值而已
但進入handleBirth後就無限迴圈。。。
拿那三個值給 this.converter.SolarToLunar(this.solar) 跑,出來的就無限迴圈?