relative image source ember js

我们两清 提交于 2019-12-11 05:38:14

问题


i have a problem with assets path in emberjs(ember-cli).

I have 2 routes: index and article route, the path for index route is just a / and the path for the article route is article/:article_id

router.js

Router.map(function() {
    this.route('article', {path : '/article/:article_id'});
});

In the idnex template, i reference my assets that are in the directory public/assets/ with the following : <img src="/assets/images/image1.jpg/> and its work great, but when i use the same tag in the article template, the image is not loaded, and the cause is that the client(browser) send the request to the server with the following url localhost:4200/article/assets/images/image1.jpg.


回答1:


I had the same issue, but using the {{rootURL}} helper solve my problem.
Example in your image tag, use something like:

<img src="{{rootURL}}assets/images/image1.jpg"/>


来源:https://stackoverflow.com/questions/41062729/relative-image-source-ember-js

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