Reference Error: Proxy is Not Defined

泄露秘密 提交于 2020-02-05 13:36:09

问题


I am trying to use ES6 Proxies in an Angular app of mine as so:

// Create defensive object using ES6 Proxy
createDefensiveObject(target) {

  return new Proxy(target, {

    get : (target, property) => {

      if(property in target) 
        return target[property];

      else
        throw new ReferenceError(`Property \"${property}\" does not exist`);
    }
  });
}

I am using Traceur to transpile everything in Chrome, and I have experimental JavaScript enabled. All other ES6 features I have implemented are working as expected, but with Proxies I get : Reference Error: Proxy is not defined

Any insight?


回答1:


Referencing this table here it would seem that Traceur has no support for ES6 proxies at this time. Babel which I use to transpile back-end code also has no support. It looks as though io.js has limited support, so further research will have to be done in order to determine whether that solution will be suitable to our needs. Though this won't help my Angular front-end.



来源:https://stackoverflow.com/questions/31348985/reference-error-proxy-is-not-defined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!