zoukankan      html  css  js  c++  java
  • vue 移动端适配 amfe-flexibl

    vue 移动端适配 amfe-flexibl

    首先下载:

    npm install  px2rem-loader --save
    
    npm install amfe-flexible --save
    main.js引入:
    
    import Vue from 'vue'
    import App from './App'
    import router from './router'
    
    
    
    // rem h5 适配
    import 'amfe-flexible/index.js'
    
    Vue.config.productionTip = false
    
    
    /* eslint-disable no-new */
    new Vue({
      el: '#app',
      router,
      components: { App },
      template: '<App/>'
    })
    
     
    build文件夹下的utils.js:
    exports.cssLoaders 中添加:
    
    const px2remLoader = {
        loader: 'px2rem-loader',
        options: {
          remUnit: 75
        }
      }
    const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader]
    改为:
    
    const loaders = options.usePostCSS ? [cssLoader, postcssLoader,px2remLoader] : [cssLoader,px2remLoader]

    关于1px转化问题: 1px转化rem后有些手机上显示模糊或不显示,解决办法:将px大写,即1px写为1PX

    原文地址:https://www.jianshu.com/p/4fe772c49a37

  • 相关阅读:
    es6
    ES6
    ES6
    css3
    滚动穿透的6种解决方案【已自测】
    css特效
    css布局
    css布局
    js
    【消灭代办】第5周
  • 原文地址:https://www.cnblogs.com/liangziaha/p/13266523.html
Copyright © 2011-2022 走看看