reactJs中定位标记中require属性的意义是什么>

问题描述 投票:0回答:1

[浏览某些教程时,我在anchor中遇到了ReactJS标记的两个实现

  1. <a id="newtD" download={'Report'} href='./reports/product/myTest.xlsx' display = "none"></a>

  2. <a id="newtD" download={'Report'} href={require('./reports/product/myTest.xlsx')} display = "none"></a>

  3. 因此,require中此href属性的意义是什么?

感谢。

[浏览某些教程时,我在ReactJS ]中遇到了锚标记的两个实现。

reactjs anchor href
1个回答
0
投票

可以使用相对路径(例如./、./foo、./bar/baz、../foo)导入本地模块和JSON文件,该相对路径将针对__dirname(如果已定义)或当前工作目录。

© www.soinside.com 2019 - 2024. All rights reserved.