我正在尝试映射图像数组并在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`)}")`,
请问该如何解决?