PanJiaChen / vue-admin-template

a vue2.0 minimal admin template
https://git.io/fAnuM
MIT License
19.99k stars 7.42k forks source link

npm run dev为什么打开两个标签页? #395

Open zjq1394288160 opened 5 years ago

zjq1394288160 commented 5 years ago

admin temlate两个全是这种情况!

4js commented 5 years ago

admin temlate两个全是这种情况!

把vue.config.js 里的devServer里的open选项给去掉

zjq1394288160 commented 5 years ago

@4js 去掉devServer里的open后要自己手动打开。不是很友好。

4js commented 5 years ago

@4js 去掉devServer里的open后要自己手动打开。不是很友好。

在package.json里面 dev命令最后追加一个“--open”

zjq1394288160 commented 5 years ago

@4js 在# #392中看到了同样的解决方案,只不过很郁闷为什么在vue.config.js配置会打开两次。我在官方vue-cli中也看到了同样的issue。 应该是官方脚手架的问题。

Lofanmi commented 5 years ago

@zjq1394288160 @4js @PanJiaChen

我也折腾了很久, 是dev-server的问题, 以下方法亲测有效:

修改package.json, 强制指定版本 "webpack-dev-server": "3.3.1"

解决了就给我点个赞吧哈哈

zjq1394288160 commented 5 years ago

@Lofanmi package.json里没有webpack-dev-server字段??

Lofanmi commented 5 years ago

@zjq1394288160 ???

https://github.com/PanJiaChen/vue-admin-template/blob/master/package.json

zjq1394288160 commented 5 years ago

@Lofanmi 你看下面是package.json文件里确实没有webpack-dev-server字段呀,咱们两个人描述的不是一个问题吗?

{
  "name": "vue-admin-template",
  "version": "4.2.1",
  "description": "A vue admin template with Element UI & axios & iconfont & permission control & lint",
  "author": "Pan <panfree23@gmail.com>",
  "license": "MIT",
  "scripts": {
    "dev": "vue-cli-service serve",
    "build:prod": "vue-cli-service build",
    "build:stage": "vue-cli-service build --mode staging",
    "preview": "node build/index.js --preview",
    "lint": "eslint --ext .js,.vue src",
    "test:unit": "jest --clearCache && vue-cli-service test:unit",
    "test:ci": "npm run lint && npm run test:unit",
    "svgo": "svgo -f src/icons/svg --config=src/icons/svgo.yml"
  },
  "dependencies": {
    "axios": "0.18.1",
    "element-ui": "2.7.2",
    "js-cookie": "2.2.0",
    "normalize.css": "7.0.0",
    "nprogress": "0.2.0",
    "path-to-regexp": "2.4.0",
    "vue": "2.6.10",
    "vue-router": "3.0.6",
    "vuex": "3.1.0"
  },
  "devDependencies": {
    "@babel/core": "7.0.0",
    "@babel/register": "7.0.0",
    "@vue/cli-plugin-babel": "3.6.0",
    "@vue/cli-plugin-eslint": "^3.9.1",
    "@vue/cli-plugin-unit-jest": "3.6.3",
    "@vue/cli-service": "3.6.0",
    "@vue/test-utils": "1.0.0-beta.29",
    "autoprefixer": "^9.5.1",
    "babel-core": "7.0.0-bridge.0",
    "babel-eslint": "10.0.1",
    "babel-jest": "23.6.0",
    "chalk": "2.4.2",
    "connect": "3.6.6",
    "eslint": "5.15.3",
    "eslint-plugin-vue": "5.2.2",
    "html-webpack-plugin": "3.2.0",
    "mockjs": "1.0.1-beta3",
    "node-sass": "^4.9.0",
    "runjs": "^4.3.2",
    "sass-loader": "^7.1.0",
    "script-ext-html-webpack-plugin": "2.1.3",
    "script-loader": "0.7.2",
    "serve-static": "^1.13.2",
    "svg-sprite-loader": "4.1.3",
    "svgo": "1.2.2",
    "vue-template-compiler": "2.6.10"
  },
  "engines": {
    "node": ">=8.9",
    "npm": ">= 3.0.0"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions"
  ]
}
Lofanmi commented 5 years ago

@zjq1394288160 里面没有, 不一定就不会安装.

你现在npm i后的, 是3.7版本, 所以我说, 强制使用3.3.1.

zjq1394288160 commented 5 years ago

@Lofanmi 你的意思是在dependencies里强制指定 "webpack-dev-server": "3.3.1"版本?

Lofanmi commented 5 years ago

@zjq1394288160

对的. 具体步骤: npm i -S webpack-dev-server@3.3.1 然后修改 dependencies: "webpack-dev-server": "3.3.1" (把^去掉)

或者你改完npm i也行

zjq1394288160 commented 5 years ago

@Lofanmi 好的我试一下!