我在react项目中使用了webpack,但是未加载图像 控制台中的错误是找不到图像 GET http:// localhost:3000 / assets / images / test.jpg 404(未找到)
{
test: /\.(png|jpe?g|gif)$/i,
loader: 'file-loader',
options: {
name: '[path][name].[ext]',
},
},
这是我的webpack配置
import React, { Component } from 'react'
import { withRouter } from 'react-router-dom'
const path = '/../../assets/images/test.jpg'
class DashboardContainer extends Component {
handleSubmit = () => {
const { history } = this.props
console.log(history)
}
render() {
console.log('here')
return (
<div>
<button onClick={this.handleSubmit}>Click me</button>
<img src={path} width="400" height="400" alt="logo"/>
</div>
)
}
}
export default withRouter(DashboardContainer)