F-loat / mpvue-entry

⛓️ 集中式页面配置,统一构建入口,支持新增页面热更新
MIT License
353 stars 56 forks source link

打包后部分页面json无usingComponents,导致页面页面引用组件不渲染 #117

Open GreenyZD opened 5 years ago

GreenyZD commented 5 years ago
  1. 使用vue init F-loat/mpvue-quickstart my-projectt构建项目

  2. package.json

    {
    "name": "jgMiniProgram",
    "version": "1.0.0",
    "description": "jgMiniProgram",
    "author": "50524",
    "private": true,
    "scripts": {
    "dev": "node build/dev-server.js",
    "start": "node build/dev-server.js",
    "build": "node build/build.js",
    "lint": "eslint --ext .js,.vue src",
    "lint:fix": "eslint --ext .js,.vue src --fix"
    },
    "dependencies": {
    "axios": "^0.18.0",
    "minapp-api-promise": "^1.0.2",
    "mpvue": "^1.0.0",
    "vuex": "^3.0.0"
    },
    "devDependencies": {
    "babel-core": "^6.26.0",
    "babel-eslint": "^8.2.0",
    "babel-loader": "^7.1.0",
    "babel-plugin-transform-runtime": "^6.22.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-stage-2": "^6.22.0",
    "babel-register": "^6.22.0",
    "chalk": "^2.4.0",
    "copy-webpack-plugin": "^4.5.0",
    "css-loader": "^0.28.0",
    "cssnano": "^3.10.0",
    "eslint": "^4.19.0",
    "eslint-config-standard": "^11.0.0",
    "eslint-friendly-formatter": "^4.0.0",
    "eslint-loader": "^2.0.0",
    "eslint-plugin-html": "^4.0.0",
    "eslint-plugin-import": "^2.11.0",
    "eslint-plugin-node": "^6.0.0",
    "eslint-plugin-promise": "^3.4.0",
    "eslint-plugin-standard": "^3.0.0",
    "extract-text-webpack-plugin": "^3.0.0",
    "file-loader": "^1.1.0",
    "friendly-errors-webpack-plugin": "^1.7.0",
    "less": "^3.9.0",
    "less-loader": "^4.1.0",
    "mpvue-config-loader": "^0.1.0",
    "mpvue-entry": "next",
    "mpvue-loader": "^1.1.2",
    "mpvue-router-patch": "^0.2.0",
    "mpvue-template-compiler": "^1.0.0",
    "mpvue-webpack-target": "^1.0.0",
    "optimize-css-assets-webpack-plugin": "^3.2.0",
    "ora": "^2.0.0",
    "postcss-loader": "^2.1.0",
    "postcss-mpvue-wxss": "^1.0.0",
    "prettier": "~1.12.0",
    "px2rpx-loader": "^0.1.0",
    "qs": "^6.6.0",
    "rimraf": "^2.6.0",
    "semver": "^5.3.0",
    "shelljs": "^0.8.0",
    "uglifyjs-webpack-plugin": "^1.2.0",
    "url-loader": "^1.0.0",
    "vant-weapp": "^0.5.10",
    "vue-style-loader": "^4.1.0",
    "webpack": "^3.11.0",
    "webpack-bundle-analyzer": "^2.13.0",
    "webpack-dev-middleware-hard-disk": "^1.12.0",
    "webpack-merge": "^4.1.0",
    "webpack-mpvue-asset-plugin": "^0.1.0"
    },
    "engines": {
    "node": ">= 4.0.0",
    "npm": ">= 3.0.0"
    },
    "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
    ]
    }
  3. app.vue全局配置

    globalConfig: {
    usingComponents: {
      'van-field': '/static/vant-weapp/dist/field/index',
      'van-icon': '/static/vant-weapp/dist/icon/index',
      'van-tag': '/static/vant-weapp/dist/tag/index',
      'van-button': '/static/vant-weapp/dist/button/index',
      'van-cell-group': '/static/vant-weapp/dist/cell-group/index',
      'van-cell': '/static/vant-weapp/dist/cell/index',
      'van-action-sheet': '/static/vant-weapp/dist/action-sheet/index',
      'van-dialog': '/static/vant-weapp/dist/dialog/index',
      'van-search': '/static/vant-weapp/dist/search/index',
      'van-toast': '/static/vant-weapp/dist/toast/index',
      'van-popup': '/static/vant-weapp/dist/popup/index',
      'van-picker': '/static/vant-weapp/dist/picker/index',
      'van-datetime-picker': '/static/vant-weapp/dist/datetime-picker/index',
      'van-swipe-cell': '/static/vant-weapp/dist/swipe-cell/index',
      'van-notice-bar': '/static/vant-weapp/dist/notice-bar/index',
      'van-notify': '/static/vant-weapp/dist/notify/index',
      'van-tab': '/static/vant-weapp/dist/tab/index',
      'van-tabs': '/static/vant-weapp/dist/tabs/index',
      'van-switch-cell': '/static/vant-weapp/dist/switch-cell/index'
    }
    },
  4. 某页面JSON文件 npm run build

    {
    "navigationBarTitleText": "电动车通行"
    }

    npm run dev

    {
    "usingComponents": {
    "van-field": "/static/vant-weapp/dist/field/index",
    "van-icon": "/static/vant-weapp/dist/icon/index",
    "van-tag": "/static/vant-weapp/dist/tag/index",
    "van-button": "/static/vant-weapp/dist/button/index",
    "van-cell-group": "/static/vant-weapp/dist/cell-group/index",
    "van-cell": "/static/vant-weapp/dist/cell/index",
    "van-action-sheet": "/static/vant-weapp/dist/action-sheet/index",
    "van-dialog": "/static/vant-weapp/dist/dialog/index",
    "van-search": "/static/vant-weapp/dist/search/index",
    "van-toast": "/static/vant-weapp/dist/toast/index",
    "van-popup": "/static/vant-weapp/dist/popup/index",
    "van-picker": "/static/vant-weapp/dist/picker/index",
    "van-datetime-picker": "/static/vant-weapp/dist/datetime-picker/index",
    "van-swipe-cell": "/static/vant-weapp/dist/swipe-cell/index",
    "van-notice-bar": "/static/vant-weapp/dist/notice-bar/index",
    "van-notify": "/static/vant-weapp/dist/notify/index",
    "van-tab": "/static/vant-weapp/dist/tab/index",
    "van-tabs": "/static/vant-weapp/dist/tabs/index",
    "van-switch-cell": "/static/vant-weapp/dist/switch-cell/index"
    },
    "navigationBarTitleText": "电动车通行"
    }
  5. 页面表现(npm run build) 页面 image wxml image

  6. 正常表现(npm run dev) 页面 image wxml image

F-loat commented 5 years ago

可以直接在 app.json 里配置全局组件

F-loat commented 5 years ago

只是 run build 有问题对吧

GreenyZD commented 5 years ago

是的------------------ 原始邮件 ------------------ 发件人: "Sam Liu"notifications@github.com 发送时间: 2019年5月30日(星期四) 上午7:07 收件人: "F-loat/mpvue-entry"mpvue-entry@noreply.github.com; 抄送: "GreenyD"930422022@qq.com;"Author"author@noreply.github.com; 主题: Re: [F-loat/mpvue-entry] 打包后部分页面json无usingComponents,导致页面页面引用组件不渲染 (#117)

只是 run build 有问题对吧

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.