zoukankan      html  css  js  c++  java
  • px2rem-loader(Vue:移动端自适应,px自动转化)

    1.下载lib-flexible

    npm i lib-flexible --save

    2.引入lib-flexible

    import 'lib-flexible/flexible'

    3.设置meta标签

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    4.安装px2rem-loader

    npm install px2rem-loader

    5.配置px2rem-loader

    在build文件中找到util.js,将px2rem-loader添加到cssLoaders中,如:

    const cssLoader = {
        loader: 'css-loader',
        options: {
          minimize: process.env.NODE_ENV === 'production',
          sourceMap: options.sourceMap
        }
      }
      const px2remLoader = {
        loader: 'px2rem-loader',
        options: {
          remUnit: 75
        }
      }

    // 同时,在generateLoaders方法中添加px2remLoader

    function generateLoaders (loader, loaderOptions) {
      const loaders = options.usePostCSS ? [cssLoader, postcssLoader, px2remLoader] : [cssLoader, px2remLoader]
    if (loader) {
      loaders.push({
      loader: loader + '-loader',
      options: Object.assign({}, loaderOptions, {
      sourceMap: options.sourceMap
      })
      })
      }

    if (options.extract) {
      return ExtractTextPlugin.extract({
      use: loaders,
      fallback: 'vue-style-loader'
      })
      } else {
      return ['vue-style-loader'].concat(loaders)
      }
    }

     

    6.重启,

    npm run dev
  • 相关阅读:
    FreeRTOS计数型信号量
    FreeRTOS二值信号量
    FreeRTOS队列操作
    ROMTableAddr = 0xE00FF003 错误 Target DLL has been cancelled 错误
    stm32 USART_IT_IDLE中断 一帧数据
    Moving to Express 4
    node.js 模板 ejs 转
    [译]JavaScript中,{}+{}等于多少?
    mongoose简单使用样例
    MongoVUE简单操作手册
  • 原文地址:https://www.cnblogs.com/panax/p/11042188.html
Copyright © 2011-2022 走看看