相对图像源ember js [英] relative image source ember js

查看:63
本文介绍了相对图像源ember js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在emberjs(ember-cli)中遇到了资产路径问题。

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

我有2条路径:索引 article 路由,索引路由的路径仅为 / ,而文章路由的路径为 article /:article_id

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'});
});

idnex 模板中,我引用了目录 public / assets / 中具有以下内容的资产:< img src = / assets / images / image1.jpg /> 及其效果很好,但是当我在文章模板中使用相同的标记时,图像未加载,并且原因是客户端(浏览器)使用以下网址 localhost:4200 / article / assets / images / image1.jpg 将请求发送到服务器。

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.

推荐答案

我遇到了同样的问题,但是使用 {{rootURL}} 助手可以解决我的问题。

在图像标签中的示例,使用类似以下内容的方法:

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"/>

这篇关于相对图像源ember js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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