我正在尝试映射一组图像并在 nextjs 应用程序中呈现。
const style = {
backgroundImage: `url("${require(`/${post.images}`)}")`,
};
我收到此错误消息:
./public/tech1.jpg 1:0
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
./public/tech2.jpg 1:0
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
./public/tech3.jpg 1:0
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
next.config.js
const withImages = require("next-images");
module.exports = withImages();
我可以渲染图像但不能动态渲染,如下所示:
backgroundImage: `url("${require(`/tech2.jpg`)}")`,
请问我该如何解决这个问题?