编辑模板meteor.js后图像不显示

时间:2022-09-06 18:50:01

Screenshot of the web app on command prompt
Screenshot of the project folder

命令提示符下的Web应用程序的屏幕截图项目文件夹的屏幕截图

I've tried editing a template in meteor.js but when I put the image file in the template, the image is not shown on the web browser image_share

我已经尝试在meteor.js中编辑模板但是当我将图像文件放在模板中时,图像不会显示在Web浏览器image_share上

<body>
  <h1>Welcome to Meteor!</h1>

  {{> images}}
</body>

<template name="images">
    <img src="public/Aliens.jpg" alt="Aliens!">
</template>

image_share is the folder which has a css file, a js file and an html file. I have created a folder public in image_share and put the image Aliens.jpg in it. When i run this on the browser, it just shows : "Welcome to Meteor! {{> images}}" The image is not shown. Where am I going wrong?

image_share是具有css文件,js文件和html文件的文件夹。我在image_share中创建了一个public文件夹,并将图像Aliens.jpg放入其中。当我在浏览器上运行它时,它只显示:“欢迎使用Meteor!{{> images}}”图像未显示。我哪里错了?

2 个解决方案

#1


0  

Just remove /public - that directory maps to /

只需删除/ public - 该目录映射到/

#2


0  

By default metoer understands that you assets like images, documents and other attachment files will be based at location of Project/public/, So you just need to specify the file name or the path from folder inside public directory. That's it bro.

默认情况下,metoer了解您的资产(如图像,文档和其他附件)将基于Project / public /的位置,因此您只需要指定文件名或公共目录中文件夹的路径。那是兄弟。

Below is examle,

以下是考试,

  1. For public/sample.jpg => path is 'sample.jpg'
  2. 对于public / sample.jpg => path是'sample.jpg'

  3. For public/IMG/sample.JPG => path is 'IMG/sample.JPG'
  4. 对于public / IMG / sample.JPG => path是'IMG / sample.JPG'

#1


0  

Just remove /public - that directory maps to /

只需删除/ public - 该目录映射到/

#2


0  

By default metoer understands that you assets like images, documents and other attachment files will be based at location of Project/public/, So you just need to specify the file name or the path from folder inside public directory. That's it bro.

默认情况下,metoer了解您的资产(如图像,文档和其他附件)将基于Project / public /的位置,因此您只需要指定文件名或公共目录中文件夹的路径。那是兄弟。

Below is examle,

以下是考试,

  1. For public/sample.jpg => path is 'sample.jpg'
  2. 对于public / sample.jpg => path是'sample.jpg'

  3. For public/IMG/sample.JPG => path is 'IMG/sample.JPG'
  4. 对于public / IMG / sample.JPG => path是'IMG / sample.JPG'