简体   繁体   English

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

[英]Image doesn't show after editing template meteor.js

Screenshot of the web app on command prompt Web应用程序在命令提示符下的屏幕截图
Screenshot of the project folder 项目文件夹的屏幕截图

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中编辑模板,但是当我将图像文件放入模板时,该图像未显示在网络浏览器中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. image_share是具有css文件,js文件和html文件的文件夹。 I have created a folder public in image_share and put the image Aliens.jpg in it. 我在image_share中创建了一个公用文件夹,并将图像Aliens.jpg放入其中。 When i run this on the browser, it just shows : "Welcome to Meteor! {{> images}}" The image is not shown. 当我在浏览器中运行此程序时,它仅显示:“ Welcome to Meteor!{{> images}}”该图像未显示。 Where am I going wrong? 我要去哪里错了?

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

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. 默认情况下,metoer理解您的资产(如图像,文档和其他附件文件)将位于Project / public /的位置,因此您只需要指定文件名或public目录中文件夹的路径即可。 That's it bro. 兄弟。

Below is examle, 下面是例子

  1. For public/sample.jpg => path is 'sample.jpg' 对于public / sample.jpg =>路径为'sample.jpg'
  2. For public/IMG/sample.JPG => path is 'IMG/sample.JPG' 对于public / IMG / sample.JPG =>路径为“ IMG / sample.JPG”

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

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