首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >%PUBLIC_URL%编辑器对WebStorm的警告

%PUBLIC_URL%编辑器对WebStorm的警告
EN

Stack Overflow用户
提问于 2018-06-03 19:44:05
回答 1查看 1.9K关注 0票数 12

在WebStorm的/public/index.html文件中,有一个指向/public的文件夹路径,标记为%PUBLIC_URL%

它找不到目录%PUBLIC_URL%,因为它不存在,这也不应该存在。

除了用<!--suppress HtmlUnknownTarget -->消除错误之外,Webstorm中是否有一种方法可以将目录变量(如%PUBLIC_URL% )别名到/public的根路径,以避免开发中出现编辑器错误?

代码语言:javascript
复制
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="theme-color" content="#000000">
    <!--
      manifest.json provides metadata used when your web app is added to the
      homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
    -->
    <link rel="manifest" href="%PUBLIC_URL%/manifest.json">
    <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
    <!--
      Notice the use of %PUBLIC_URL% in the tags above.
      It will be replaced with the URL of the `public` folder during the build.
      Only files inside the `public` folder can be referenced from the HTML.

      Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
      work correctly both with client-side routing and a non-root public URL.
      Learn how to configure a non-root public URL by running `npm run build`.
    -->
    <title>React App</title>
</head>
EN

回答 1

Stack Overflow用户

发布于 2020-07-08 13:09:02

这篇文章似乎给出了更多关于这一点的内容:

https://medium.com/@jenniferdobak/the-public-folder-and-favicons-in-create-react-app-8dc2cc1d492b

这是一个很好的时间来解决这个看起来古怪的%PULIC_URL%标签。还记得我们在公用文件夹中放置资产时所提供的“逃逸舱口”反应吗?在构建过程中,以%PULIC_URL%标记为前缀的资产将被识别和遵守。然而,这不是最佳做法,只应在必要时使用。

因此,在大多数情况下,您可以使用类似于公共的东西来代替%PUBLIC_URL%,但是当然,这取决于您如何构建您的React项目。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50670349

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档