首页 > 解决方案 > SPFX webpart 引用 html 中的图像

问题描述

我正在使用 SPFX 创建一个简单的 SharePoint Webpart,我想在解决方案中引用图像。我使用了这种方法:

require("@microsoft/loader-set-webpack-public-path!");

<img src="${require<string>('../../assets/logo.jpg')}" alt="My Company" />

但它不起作用。

如何做到这一点?

标签: htmlsharepointspfx

解决方案


示例测试演示:

无框架:

<img src="${require<string>('../../download.jpg')}" alt="My Company" />

在此处输入图像描述

反应框架:

在此处输入图像描述

<img src={require('../../assets/panda.jpg')} alt="test" />

推荐阅读