基于Vue的PC和移动端适配的实现方案

1.package.json (vue-cli 版本 14.0.x, postcss 版本 7.x)

{
  "name": "front-project",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "core-js": "^3.6.5",
    "cssnano": "^5.0.14",
    "element-ui": "^2.15.6",
    "postcss-aspect-ratio-mini": "^1.1.0",
    "postcss-cssnext": "^3.1.1",
    "postcss-px-to-viewport": "^1.1.1",
    "postcss-viewport-units": "^0.1.6",
    "postcss-write-svg": "^3.0.1",
    "vue": "^2.6.11",
    "vue-router": "^3.5.3"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "~4.5.0",
    "@vue/cli-plugin-eslint": "~4.5.0",
    "@vue/cli-service": "~4.5.0",
    "babel-eslint": "^10.1.0",
    "cssnano-preset-advanced": "^5.1.9",
    "eslint": "^6.7.2",
    "eslint-plugin-vue": "^6.2.2",
    "postcss": "^7.0.39",
    "postcss-import": "^12.0.1",
    "postcss-url": "^8.0.0",
    "sass": "^1.26.10",
    "sass-loader": "^8.0.2",
    "vue-template-compiler": "^2.6.11"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "eslint:recommended"
    ],
    "parserOptions": {
      "parser": "babel-eslint"
    },
    "rules": {}
  },
  "browserslist": [
    "> 1%",
    "last 2 versions"
  ]
}

2、新建 .postcssrc.js 文件,文件配置:

module.exports = {
    "plugins": {
        "postcss-import": {},
        "postcss-url": {},
        "postcss-aspect-ratio-mini": {},
        "postcss-write-svg": {utf8: false},
        "postcss-cssnext": {},
        "postcss-px-to-viewport": {
            "viewportWidth": 750,
            "minPixelValue": 1,
            "mediaQuery": false,
            "selectorBlackList": ["van", "el"],
            "landscape": true,
            "landscapeUnit": "vw",
            "landscapeWidth": 2048
        },
        "postcss-viewport-units": {filterRule: rule => rule.nodes.findIndex(i => i.prop === "content") === -1},
    }
}



作者:一个头发茂密的程序员
链接:https://www.jianshu.com/p/c93a31bb748c
 

相关资源:

Python入门基础教程全套

GitOps 初探

 mysql教程

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值