获取RESTAdapter主机 [英] Get RESTAdapter host

查看:69
本文介绍了获取RESTAdapter主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

RESTAdapter可以为后端指定一个URL:

RESTAdapter has the possibility to specify a url for the backend:

DS.RESTAdapter.reopen({
  url: 'https://api.example.com'
});

如何通过编程方式访问此属性?我的意思是这样的: DS.RESTAdapter.get('url')<-这不起作用

How can I access this property programmatically? I mean something like: DS.RESTAdapter.get('url') <-This doesn't work

推荐答案

您要在类而非实例上设置属性,这就是为什么无法检索值的原因。有两种可能的解决方案。

You're setting the properties on the class not the instance, thats why you can't retrieve the values. There are two possible solutions.

您可以从原型中获取值

DS.RESTAdapter.prototype.url

或者您可以实例化该类并从那里获取它

or you can instantiate the class and get it from there

DS.RESTAdapter.create().url

这篇关于获取RESTAdapter主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆