Ember 模板中的 rootURL
Ember rootURL in templates
我正在尝试将我的应用程序从 baseURL 迁移到 rootURL 路由器配置。我无法确定将哪个 url 用于我模板中 public/assets 中存储的图像。
在我使用 assets/images/myimage.png
之前,现在我想做类似 {{rootURL}}assets/images/myimage.png
的事情,但是从路由中注入它似乎很老套。
setupController(controller, model) {
this._super(controller, model);
this.controllerFor('application').set('rootURL', this.get('router.rootURL'));
}
是否有既定的方法来做到这一点?
提前致谢。
您可以像 import config from 'app-name/config/environment'
一样导入它并像 config.rootURL
一样使用它
我正在尝试将我的应用程序从 baseURL 迁移到 rootURL 路由器配置。我无法确定将哪个 url 用于我模板中 public/assets 中存储的图像。
在我使用 assets/images/myimage.png
之前,现在我想做类似 {{rootURL}}assets/images/myimage.png
的事情,但是从路由中注入它似乎很老套。
setupController(controller, model) {
this._super(controller, model);
this.controllerFor('application').set('rootURL', this.get('router.rootURL'));
}
是否有既定的方法来做到这一点?
提前致谢。
您可以像 import config from 'app-name/config/environment'
一样导入它并像 config.rootURL