data return number 0 ; fetchDatascsId var _this = this; unirequest url uni$uhttpconfigbaseURL + frontinterpretscenicSpotInterpretList method GET data scsId scsId
代码中存在两个问题:
-
在fetchData函数中,使用箭头函数作为success回调函数,导致this指向的是箭头函数所在的上下文,而不是vue实例。因此,无法通过this访问到vue实例的属性和方法。解决方法是使用普通函数或者使用bind方法将this绑定到回调函数中。
-
在for循环中,将this.number赋值给audioList[i].audioName。然而,this.number在data函数中定义,而在for循环中使用的this指向的是for循环的上下文,而非vue实例。因此,无法访问到this.number属性。解决方法是在for循环外部将this.number保存到一个变量中,然后在for循环中使用该变量。
原文地址: https://www.cveoy.top/t/topic/iTmi 著作权归作者所有。请勿转载和采集!