javascript - 无法解析 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
。
为什么?
解决方案
推荐阅读
- amazon-web-services - AWS CloudFormation Fn::Join - 转义单引号
- c++ - Python 的 C++ 枚举
- javascript - Google API 不会翻译外文字母。
- node.js - AJAX 删除问题
- apache - Apache忽略AllowOverride = All和Rewrite模块启用的重写规则
- c# - 使用 REST API 部署 Azure 资源
- jquery - Jquery Comments.js 给定的范围不在文档中
- spring - Spring BasicAuthenticationFilter.doFilter() 非常慢
- powershell - 使用 PowerShell 在目录和子文件夹中使用给定名称重命名批量文件
- sql - 将 Unixtime 转换为 MMddyyyy