Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在动态路由上使用相对图像路径,在图像之前添加路由,请参见此处。
为什么是这样?有没有办法使用动态路径来使用相对图像路径?这在任何地方都有记录吗?
相对图像路径以动态路径为前缀,因为相对图像路径缺少前导/.
/
所以,假设我们正在访问一条动态路线foo-bar。下面的图像路径将:
foo-bar
/assets/images/foo.png-><protocol>://<host>/assets/images/foo.png
/assets/images/foo.png
<protocol>://<host>/assets/images/foo.png
assets/images/foo.png-><protocol>://<host>/foo-bar/assets/images/foo.png
assets/images/foo.png
<protocol>://<host>/foo-bar/assets/images/foo.png
这不是 Ember.js 的东西,它是浏览器和文件路径的东西。
考虑答案https://stackoverflow.com/a/7613355/631730。