Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[grid-item] 为什么不能使用本地的图片进行渲染 #2493

Open
7757 opened this issue Dec 14, 2023 · 2 comments
Open

[grid-item] 为什么不能使用本地的图片进行渲染 #2493

7757 opened this issue Dec 14, 2023 · 2 comments
Labels
question This is a question, not a bug

Comments

@7757
Copy link

7757 commented Dec 14, 2023

这个功能解决了什么问题

<t-grid-item  t-class="grid" image="../../images/icon/systeminfo.png" badge-props="{{ { count: 8 } }}" />

控制台报渲染错误
实测 image 标签可以渲染

你建议的方案是什么

建议支持本地图片渲染

Copy link
Contributor

👋 @7757,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

@anlyyao
Copy link
Collaborator

anlyyao commented Feb 20, 2024

@7757 原因:grid-item使用的是t-image组件(二封的原生image),所以使用本地图片相对路径时,这个路径不是相对于调用组件的文件的位置,要相对于t-iamge图片组件源码的位置。

这里提供一个容易理解和执行的使用本地图片的方式:改用相对根路径。

  1. 新建与pages文件夹同级目录,如assets文件夹,这个文件夹下放本地图片
  2. 此时图片路径应该为 /assets/xxx.jpg
企业微信截图_cd918954-2c13-4488-aa52-dba24f314032

@anlyyao anlyyao added the question This is a question, not a bug label Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question This is a question, not a bug
Projects
None yet
Development

No branches or pull requests

2 participants