为什么数组this.temp.researcherAndFundManagerSelect.push('c2013159-7f2a-45fb-abfa-2ae8eb7adb43')第二句就不执行了
时间: 2024-01-12 09:05:38 浏览: 37
可能是因为`this.temp.researcherAndFundManagerSelect`不是一个数组类型,或者已经被修改为其他类型了。如果`this.temp.researcherAndFundManagerSelect`不是一个数组类型,那么调用`push`方法就会报错,导致后面的代码无法执行。如果`this.temp.researcherAndFundManagerSelect`已经被修改为其他类型,那么可能就没有`push`方法了,也会导致后面的代码无法执行。
你可以在调用`push`方法之前,先使用`console.log`打印一下`this.temp.researcherAndFundManagerSelect`,确保它是一个数组类型,并且没有被修改为其他类型。另外,你也可以尝试使用`this.$set`方法或者`Vue.set`方法来添加数组元素,例如:
```javascript
// 使用 this.$set 方法添加数组元素
this.$set(this.temp.researcherAndFundManagerSelect, this.temp.researcherAndFundManagerSelect.length, 'c2013159-7f2a-45fb-abfa-2ae8eb7adb43')
// 使用 Vue.set 方法添加数组元素
Vue.set(this.temp.researcherAndFundManagerSelect, this.temp.researcherAndFundManagerSelect.length, 'c2013159-7f2a-45fb-abfa-2ae8eb7adb43')
```
这两个方法都可以添加数组元素,并且能够确保Vue能够检测到数组的变化。
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)