Giter Site home page Giter Site logo

Comments (5)

wswmsword avatar wswmsword commented on May 20, 2024

我不确定这个是不是之前版本的问题,可能要麻烦您升下最新版本,看看还有没有这个问题,我给你整了下新版本的配置,我看你装的版本是 2.2.2,最新的是 3.2.2:

const autoprefixer = require('autoprefixer')
const viewport = require('postcss-mobile-forever')

const baseViewOpts = {
  rootSelector: "#app",
  viewportWidth: 750,
  unitPrecision: 3,
  propList: ['*'],
  selectorBlackList: ['.ignore', 'keep-px'],
  exclude: /node_modules(?![\\/]vant)/, // <---- 这里的 exclude 不能包括 vant,我看你下面要转换 vant 视图,这里排除 node_modules 所有文件之后 vant 应该也不会转换了
  border: true,
  disableDesktop: false,
  disableLandscape: false,
  mobileUnit: 'vw',
}

module.exports = {
  plugins: [
    autoprefixer(),
    viewport({
      ...baseViewOpts,
      viewportWidth: file => file.includes('node_modules/vant/') ? 375 : 750,
    })
  ]
}

重新卸载再重装就是最新版了:

npm uninstall postcss-mobile-forever
npm i postcss-mobile-forever --save-dev

如果还有问题我及时修复。

from postcss-mobile-forever.

ren2436 avatar ren2436 commented on May 20, 2024

vite-vue3-test.zip
我使用最新版的搭建了一个最小的包,麻烦您看下,还是有这个问题
我这定位到是这行 出现的问题,注释掉就没问题了
viewportWidth: (file) => (file.includes('node_modules/vant/') ? 375 : 750),

from postcss-mobile-forever.

ren2436 avatar ren2436 commented on May 20, 2024

node版本为 18.14.2

from postcss-mobile-forever.

wswmsword avatar wswmsword commented on May 20, 2024

vite-vue3-test.zip 我使用最新版的搭建了一个最小的包,麻烦您看下,还是有这个问题 我这定位到是这行 出现的问题,注释掉就没问题了 viewportWidth: (file) => (file.includes('node_modules/vant/') ? 375 : 750),

好,谢谢,我看下

from postcss-mobile-forever.

wswmsword avatar wswmsword commented on May 20, 2024

@ren2436 已修复,修复版本是 3.2.3 ^_^

传递计算后的 viewportWidth 值传错了,传成了函数,最后除的函数,结果就是 NaN 了。

from postcss-mobile-forever.

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.