不是从CSS文件加载的图像,它是用于后台的,但在jsx中它正在加载
在CSS文件中,我使用了如下所示
.main-banner {
position: relative;
height: 910px;
z-index: 1;
background: transparent url(../../static/images/banner-bg1.jpg) right top no-repeat;
}图像URL是绝对好的
和像这样的配置文件
//next.config.js
const withImages = require('next-images');
const withCSS = require('@zeit/next-css')
module.exports = withImages(withCSS({
cssLoaderOptions: {
url: false
}
}))究竟是甚麽问题呢?
谢谢
发布于 2019-04-03 06:51:15
您的静态文件正在部署到web的根目录中。与编译后的js和css文件相同。
因此,您可以使用以下url访问它们:url(/static/images/banner-bg1.jpg)
有关这 github问题的更多信息。
发布于 2020-11-26 15:38:44
我收到了css道具背景图像中的对象模块。在url中标记esModule: false -加载程序选项解决了这个问题。
const withCSS = require('@zeit/next-css');
const nextConfig = withCSS({
webpack(config, options) {
config.module.rules.push({
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
use: {
loader: 'url-loader',
options: {
limit: 100000,
esModule: false,
name: '[name].[ext]'
}
}
});
return config;
}
});https://stackoverflow.com/questions/55487534
复制相似问题