在条件判断中,应该使用双等号(==)或者三等号(===)来判断相等性,而不是单等号(=)赋值。所以在if(item.parentid=pid)这一行,应该改为if(item.parentid === pid)

const arrayData = id 2 title 中国 parentid 0 id 3 title 广东省 parentid 2 id 4 title 广州市 parentid 3 id 5 title 天河区 parentid 4 id 6 title 湖南省 parentid 2 id 1 title 俄罗斯 parentid 0 function

原文地址: https://www.cveoy.top/t/topic/iJ87 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录