vue移动端的真机测试

Vue2.0

    在 package.json 文件里加入 --host 0.0.0.0,需要重新运行 npm run dev

{
	"name": "",
    "version": "1.0.0",
    "description": "A Vue.js project",
    "author": "",
    "private": true,
    "scripts": {
        "dev": "webpack-dev-server --host 0.0.0.0 --inline --progress --config build/webpack.dev.conf.js",
        "start": "npm run dev",
        "build": "node build/build.js"
    },
    "dependencies": {
        "axios": "^0.18.0",
        "better-scroll": "^1.14.1",
        "fastclick": "^1.0.6",
        "stylus": "^0.54.5",
        "stylus-loader": "^3.0.2",
        "vue": "^2.5.2",
        "vue-awesome-swiper": "^2.6.7",
        "vue-router": "^3.0.1",
        "vuex": "^3.1.0"
    }
}

Vue3.0

    在 package.json 文件里加入 --host 0.0.0.0,需要重新运行 npm run serve

{
  "name": "",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve --host 0.0.0.0",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint",
    "test:unit": "vue-cli-service test:unit"
  },
  "dependencies": {
    "core-js": "^2.6.5",
    "vue": "^2.6.10",
    "vue-awesome-swiper": "^3.1.3",
    "vue-router": "^3.0.3",
    "vuex": "^3.0.1"
  }
}

在cmd命令窗口中输入 ipconfig 获取IP

vue移动端的真机测试_第1张图片

在手机浏览器里输入IP+端口号

vue移动端的真机测试_第2张图片
注意:手机和电脑要在同一局域网下,也就是连接同一个 Internet 网络

你可能感兴趣的:(Vue,移动端,真机测试,vue.js,javascript,es6)