且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从ember.js中的.json文件中检索模型

更新时间:2023-10-06 21:49:28

@claptimes解决方案可能会工作,但它会复制原始的实现,我认为这是一个不好的做法,因为你必须手动保持最新版本的ember数据:)

@claptimes solution would probably work, but it copies the original implementation which I think is a bad practice since you'll have to manually keep it up to date to the latest version of ember data:)

此外,我注意到您正在设置已被弃用一段时间的 url 属性( https://github.com/emberjs/data/blob/eeb6162f65513caa19ce18887c3f4d1c2014d80c/TRANSITION.md #host-and-namespace-configuration )。

Also I noticed you're setting the url property which has been deprecated for a while (https://github.com/emberjs/data/blob/eeb6162f65513caa19ce18887c3f4d1c2014d80c/TRANSITION.md#host-and-namespace-configuration).

这里有一个解决方案,调用 _super 和不覆盖完整的方法:

Here is a solution that calls _super and doesn't override the complete method:

App.ApplicationAdapter = DS.RESTAdapter.extend({
  buildURL: function() {
    return this._super(...arguments) + '.json';
  }
});