gpt4 book ai didi

css - 引用错误 : window is not defined import css

转载 作者:行者123 更新时间:2023-11-27 23:54:35 25 4
gpt4 key购买 nike

试图在 react js 应用程序中导入 css 但它抛出以下错误

这是一个仪表板应用程序,其中节点 js 在服务器端, react js 在客户端

webpack.base.js

  module.exports = {
//Running babel to every file
module: {
rules: [
{
test: /\.js?$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: {
presets: [
'react',
'stage-0',
['env', { targets: { browsers: ['last 2 versions'] } }]
]
}
}, {
test: /\.css$/,
loader: "style-loader!css-loader"
}, {
test: /\.(jpe?g|png|gif|woff|woff2|eot|ttf|svg)(\?[a-z0-9=.]+)?$/,
loader: 'url-loader?limit=100000'
}

]
}//end module
}

样式.css

.segment {
border-top:14px solid #14a767;
border-bottom: 3px solid #14a767;
margin: 2px 2px 2px 140px;
width: 80%
}

Home.js(组件)

import '../../css/style.css'
return window && document && document.all && !window.atob;
^

ReferenceError: window is not defined

最佳答案

实际问题是我使用了语义 UI react 节点模块,并且每个组件都有自己的样式。就是这样,它不允许我创建具有类样式的 css,.,.所以我没有使用 class style,而是使用了 ID,而且效果很好。,

我的确切问题是这个::: custom className semantic ui react

关于css - 引用错误 : window is not defined import css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56334985/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com