2017-08-11 53 views
0

我有一個應用程序,我在數據庫中存儲圖像路徑。路徑是相對於我的文件系統而不是項目。ReactJS從項目外的文件系統加載圖像

當我問題陣營:

<img alt={this.props.alt} src={require('/fs/storage/images/logo.jpg')}/> 

I'm收到以下錯誤:

You attempted to import /fs/storage/images/logo.jpg which falls outside of the project 
src/ directory. Relative imports outside of src/ are not supported. 
You can either move it inside src/, or add a symlink to it from project's node_modules. 

我該如何解決呢?我應該在哪裏放置該消息所建議的符號鏈接?

+0

*的JavaScript。 –

回答

0

如何在客戶端讀取文件系統或數據庫? 你有服務器嗎?與數據庫通信?

你應該在服務器中讀取圖像和發送的客戶端,在那裏用它起反應,因此運行在客戶端瀏覽器*沒有訪問文件系統