reactjs - 无法导入 css 文件说错误意外令牌
问题描述
我的 reactjs 应用程序运行成功。
现在我需要导入 css 文件**(style.css)**
添加后运行代码时,import "./styles.css";
会显示错误意外令牌。
import {initializeBlock, Input, useBase, useRecords} from '@airtable/blocks/ui';
import React, { Component, useState } from "react";
import ReactDOM from 'react-dom';
import "./styles.css";
class Access extends React.Component {
//content goes here
}
我遵循了Webbars 链接建议的解决方案,并且 按照Webbars 先生的建议 安装了webpack、style-loader 和 css-loader ,但是当我尝试导入 css 文件时,意外令牌的错误仍然存在。
这是我的 webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: [ 'style-loader', 'css-loader' ]
}
]
}
}
这是我的 package.json
{
"dependencies": {
"@airtable/blocks": "0.0.51",
"react": "^16.13.0",
"react-dom": "^16.13.0",
"react-js-pagination": "^3.0.3",
"react-router-dom": "^5.2.0"
},
"devDependencies": {
"css-loader": "^3.5.3",
"eslint": "^6.8.0",
"eslint-plugin-react": "^7.18.3",
"eslint-plugin-react-hooks": "^2.5.0",
"style-loader": "^1.2.1",
"webpack": "^4.43.0"
},
"scripts": {
"lint": "eslint frontend"
}
}
解决方案
推荐阅读
- bixby - 在 Bixby 中,有没有办法以特定顺序在图像选择器中显示图像或按图像名称对其进行排序?
- ios - 如何在滚动条上隐藏搜索栏?(没有 UITableViewController)
- machine-learning - 自然语言处理、机器学习、数据科学
- javascript - 有没有办法将视频数据从视频标签/MediaStream 发送到 OffscreenCanvas?
- bootstrap-4 - 导航栏链接之间的 Bootstrap 4 响应中心徽标
- string - 我从 api 将 Json 作为字符串返回,但在 javascript 的客户端上它以对象的形式出现
- android - 通过 CALL_PHONE 直接呼叫
- php - 多酒店预订系统的数据库设计/结构
- python - 我在这段代码中做错了什么我一直坚持
- php - PHP 通过电子邮件安全地发送 GET 请求