0

npm run build因此,如果我的应用程序通过它通常的地址运行,我可以获取数据。但是npm start它不知道/(无法到达)指定的位置。

那么我该怎么做才能让它在两端都起作用呢?

包.json

{
  "name": "reactjs",
  "version": "0.1.0",
  "private": true,
  "homepage": "/reactjs/build",
  "devDependencies": {
    "lite-server": "^2.2.2",
    "react-scripts": "0.8.4"
  },  
  "dependencies": {
    "datatables.net": "^1.4.2",
    "datatables.net-dt": "^1.4.2",
    "griddle-react": "^0.7.1",
    "jquery": "^3.1.1",
    "react": "^15.4.1",
    "react-dom": "^15.4.1",
    "react-router": "^3.0.0"
  },  
  "scripts": {
    "start": "react-scripts start eslint-disable",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject",
    "dev": "lite-server -c config/bs-config.js"
  }
}
4

1 回答 1

0

向它添加代理,例如

"homepage": "/reactjs/build",
"proxy": "http://localhost/supermarkets
于 2017-09-10T02:12:22.200 回答