简体   繁体   English

重定向后,FlowRouter本地服务的图像中断

[英]FlowRouter locally served images break after redirect

While using FlowRouter if I load my page any locally served images (images/myImage.png) works fine. 使用FlowRouter时,如果我加载我的页面任何本地服务的图像(images / myImage.png)工作正常。 But if I navigate to a page and then navigate back (home page -> about page -> home page) the image is broken. 但是如果我导航到一个页面然后导航回来(主页 - >关于页面 - >主页),图像就会被破坏。 However in the developer console, if I hover over the image source, the image appears fine. 但是在开发人员控制台中,如果我将鼠标悬停在图像源上,则图像显示正常。

This is not an issue with images served from another server. 对于从其他服务器提供的图像,这不是问题。

Update I never solved this issue, but because this still seems to be an issue with many people. 更新我从未解决过这个问题,但因为这似乎仍然是许多人的问题。 I'm posting my work around. 我正在发布我的工作。 Based on the Meteor communities advice, I switched to cloud based image hosting like Cloudinary or AWS 根据Meteor社区的建议,我改用了基于云的图像托管,如Cloudinary或AWS

It sounds like you are sometimes accessing images using their file paths. 听起来有时您使用文件路径访问图像。 With Meteor, to serve static files properly, they need to be in the /public folder of your project. 使用Meteor,要正确提供静态文件,它们需要位于项目的/public文件夹中。 So you should put them in /public/images , and then reference them according to the following example: 所以你应该将它们放在/public/images ,然后根据以下示例引用它们:

The file 文件

/public/images/foo.png

is displayed by 显示

<img src="/images/foo.png>

See here: https://guide.meteor.com/structure.html#special-directories 请参阅此处: https//guide.meteor.com/structure.html#special-directories

I realized that although my images worked with the following: 我意识到虽然我的图像使用了以下内容:

Image is in /public/images/name.png 图像位于/public/images/name.png中

<img src="images/name.png">

But then I changed the url to: 但后来我把网址更改为:

<img src="/images/name.png">

Now it works and doesn't break. 现在它有效并且不会破坏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM