http://localhost:8080/ Cannot GET /

环境:

$ webpack -v
4.29.6
$ npm -v
6.4.1
$ node -v
v8.12.0
  1. 克隆vue-countTo项目,
$ git clone https://github.com/PanJiaChen/vue-countTo
  1. 然后$ npm run dev
PS E:\01project\01github\vue-countTo> npm run dev
> vue-count-to@1.0.13 dev E:\01project\01github\vue-countTo
> cross-env NODE_ENV=development webpack-dev-server --open --hot --content-base='./demo/'

Project is running at http://localhost:8080/
webpack output is served from /dist/
Content not from webpack is served from E:\01project\01github\vue-countTo\'.\demo\' 	//这里路径需要设置
404s will fallback to /index.html

地址栏http://localhost:8080/页面显示 Cannot GET /

解决方法:
3. 修改webpack.config.js文件

// webpack.config.js中添加如下一行
  devServer: {
    contentBase: path.join(__dirname, 'demo'),// 这是要添加的一行
    historyApiFallback: true,
    noInfo: true
  },
  1. 关闭$ npm run dev,重新$ npm run dev
PS E:\01project\01github\vue-countTo> npm run dev

> vue-count-to@1.0.13 dev E:\01project\01github\vue-countTo
> cross-env NODE_ENV=development webpack-dev-server --open --hot --content-base='./demo/'

Project is running at http://localhost:8080/
webpack output is served from /dist/
Content not from webpack is served from E:\01project\01github\vue-countTo\demo
404s will fallback to /index.html

现在地址栏http://localhost:8080/页面显示 demo页面的内容了!

Logo

前往低代码交流专区

更多推荐