下面这种写法如果变量val为null或者undefined,控制台会报错
handleSelectionChange (val) {
this.batchDelName = val[0].environmentName
}
下面使用了js新语法,可选链操作符,当变量val为null或者undefined时,控制台也不会报错
handleSelectionChange (val) {
this.batchDelName = val[0]?.environmentName
}