簡體   English   中英

將圖像導入 React 組件時出錯

[英]Error Importing Image into React Component

我有一個images文件夾,其中包含一張圖像stock.jpg 當我嘗試使用import {stock} from '../images/stock.jpg'將其導入我的電影組件時,出現錯誤Attempted import error: 'stock' is not exported from '../images/stock.jpg' . 導入中的文件路徑對我來說很好,這是我的目錄結構目錄結構

我究竟做錯了什么?

再次嘗試在without {}導出

import ImageJPG from "../images/stock.jpg";

如果是svg

import {ReactComponent as ImageSVG} from "../images/stock.svg"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM