我正在尝试使一些现有的JS向后兼容.如果方法不存在,我需要覆盖一个方法,否则只返回现有方法.
这是我到目前为止的代码:
this.grid.getDataSource = function(){
if (getDataSource == undefined)
return getStore();
else
return getDataSource();
}
Run Code Online (Sandbox Code Playgroud)
但是它会在"if"行上返回错误:
getDataSource未定义
解决这个问题的最佳方式是什么?
| 归档时间: |
|
| 查看次数: |
209 次 |
| 最近记录: |