相关疑难解决方法(0)

创建React App index.html和index.js连接

我开始玩Create React App,但我无法理解它index.js是如何加载的index.html.HTML代码是这样的:

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
    <!--
      Notice the use of %PUBLIC_URL% in the tag 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 …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs

47
推荐指数
1
解决办法
2万
查看次数

在 js 文件中使用 sass 变量 create-react-app

我有一些颜色定义的变量到_colors.scss文件中。

$color-succcess: #706caa;
$color-error: #dc3545;
Run Code Online (Sandbox Code Playgroud)

我还想将它们用于一些样式化的 React 组件react-table到我的 js 文件中。

我使用以下文章https://til.hashrocket.com/posts/sxbrscjuqu-share-scss-variables-with-javascript作为参考,还有许多其他人喜欢它,但我无法让它工作。

我从我的 scss 文件中导出颜色:

:export {
  colorSuccess: $color-succcess;
  colorError: $color-error;
}
Run Code Online (Sandbox Code Playgroud)

我将它们导入到我的 js 文件中:

import colors from "../../styles/_colors.scss";

但他们可能没有正确加载。

我如何配置 create-react-app 生成的代码以实现与文章中的人使用 webpack 所做的相同的事情。

javascript sass reactjs create-react-app

4
推荐指数
2
解决办法
3955
查看次数

标签 统计

javascript ×2

reactjs ×2

create-react-app ×1

sass ×1