首页 > 解决方案 > 无法解析 Vue 函数中的变量

问题描述

data: function () {
         return {
          selectedScope:'',
        }
      },



methods: {
   displayScope: function(newScope) {
            console.log(this.selectedScope)

            var resultArray = []
            this.tableData.forEach(function (data) {

                if (data.iog === this.selectedScope) {   // This is where the error 
                    resultArray.push(data)
                }
            });

        }
}

我似乎无法弄清楚为什么我得到:

无法读取未定义的属性“selectedScope”

里面forEach

为什么?

标签: javascriptvue.jsvuejs2vuex

解决方案


推荐阅读