Giter Site home page Giter Site logo

Comments (2)

sonofmagic avatar sonofmagic commented on June 26, 2024

这个也是通过配置 postcss 插件做到 px->rpx 的,这里我们使用目前这方面最流行的 taro 团队的 postcss-pxtransform 来做,你可以这样配置:

    require('postcss-pxtransform')({
      platform: 'weapp',
      // https://taro-docs.jd.com/docs/size
      // 根据你的设计稿宽度进行配置
      // 可以传入一个 function
      // designWidth (input) {
      //   if (input.file.replace(/\\+/g, '/').indexOf('@nutui/nutui-taro') > -1) {
      //     return 375
      //   }
      //   return 750
      // },
      designWidth: 750, // 375,

      deviceRatio: {
        640: 2.34 / 2,
        // 此时应用到的规则,代表 1px = 1rpx
        750: 1,
        828: 1.81 / 2,
        // 假如你把 designWidth 设置成 375 则使用这条规则 1px = 2rpx
        375: 2 / 1
      }
    })

把它加到 postcss-rem-to-responsive-pixel 后面即可

可以参考配置: https://github.com/sonofmagic/uni-app-vite-vue3-tailwind-vscode-template/blob/main/postcss.config.cjs

from weapp-tailwindcss.

chentianxin avatar chentianxin commented on June 26, 2024

感谢🙇‍

from weapp-tailwindcss.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.