Skip to content

Taro 场景下 NutUI 默认设计尺寸是375,项目里设计稿用的 750 怎么办 #779

Answered by richard1015
richard1015 asked this question in Q&A
Discussion options

You must be logged in to vote

解决方案看这个 #1122

Taro3.4.3版本之前: 解决方案

// config/index.js
const config = {
  // ...
  mini: {
    postcss: {
      pxtransform: {
        enable: true,
        config: {
          selectorBlackList: [/nut-/]
        }
      }
    }
  },
}

Taro3.4.3版本:解决方案

  postcss: {
      pxtransform: {
        enable: true,
        config: {
          // selectorBlackList: ['nut-']
          designWidth (input) {
            const isNutUi = input.file.replace(/\\+/g, '/').indexOf('@nutui/nutui-taro') > -1
            return isNutUi ? 375 : 750
          }
        }
      }
 }

Taro3.4.3 具体变更内容可查看
https://github.com/NervJS/taro/tree/next/packages/postcss-pxtransform

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@CoderBCat
Comment options

@lonelyWalkor
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by richard1015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants