Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uniapp编译为小程序后!前缀转换错误 #134

Closed
jipika opened this issue Dec 14, 2022 · 13 comments
Closed

uniapp编译为小程序后!前缀转换错误 #134

jipika opened this issue Dec 14, 2022 · 13 comments
Assignees
Labels
question Further information is requested

Comments

@jipika
Copy link

jipika commented Dec 14, 2022

在uniapp 中
image
编译为小程序后!没有了并且失去了important
image

@jipika jipika added the bug Something isn't working label Dec 14, 2022
@sonofmagic
Copy link
Owner

这个应该是 uni-app 把它自动转化成了 js 的表达式,你能告诉我 uni-app vue 的版本 (2/3),webpack or vite
还有转化的出来的放在 dist/mp-weixin 目录下,对应的 wxml 片段吗?

我怀疑直接被转成了
e 被放入了 js 里面

这种情况,可能需要用到 import { replaceJs } from 'weapp-tailwindcss-webpack-plugin/replace'

@jipika
Copy link
Author

jipika commented Dec 14, 2022

vue2
"webpack": "^4.46.0"
编译后的代码片段
class="{{['overflow-hidden','_div','data-v-9d228f9a',[!maxFull?'popup':''],className,[type=='bottom'&&!className?'rounded-t-lg _i_w-full':'']]}}"

@jipika
Copy link
Author

jipika commented Dec 14, 2022

image
image
他似乎不见了

@sonofmagic

This comment was marked as duplicate.

@sonofmagic
Copy link
Owner

上面第一张图,那个vue里完整的判断条件也粘贴给我看看吧,我复现一下,谢啦

@jipika
Copy link
Author

jipika commented Dec 14, 2022

:class="[{ popup: !maxFull }, className, { 'rounded-t-lg !w-full': type == 'bottom' && !className }]"
不好意思网络有点差

@sonofmagic
Copy link
Owner

sonofmagic commented Dec 14, 2022

微信截图_20221214150256
微信截图_20221214150312
我试了一下,我这是好的,挺奇怪的哈。
我的 uni-app 版本是 2.0.2-3061320221209001 也是用的 vue2
用的插件版本为 "weapp-tailwindcss-webpack-plugin": "^1.12.6"

这个 demo 地址,你可以点击上面的 commit that referenced link 看到

可能这个bug还有更多细节条件,才能触发。

@jipika
Copy link
Author

jipika commented Dec 14, 2022

我这边用的是最新版本的HX忘记说了,不好意思..

@jipika
Copy link
Author

jipika commented Dec 14, 2022

我找到原因了
image
父组件调用的时候传参到className就会出现这个错误

@jipika
Copy link
Author

jipika commented Dec 14, 2022

取值的其实是className

@sonofmagic
Copy link
Owner

这个问题其实和 issues/129 是一样的,
因为插件默认转义只有 classhover-class 这类的字段, className 这种并不在范围内,所以假如你们约定 className 作为统一传递的 prop 的话,可以这样配置:

      new UniAppWeappTailwindcssWebpackPluginV4({
        customAttributes: {
         // * 通配符,代表所有的标签都生效
          '*': ['className']
         // 数组里同时允许 字符串 和正则
         // '*': [/className/],
        }

这样 className 就能被顺利转义了

@sonofmagic sonofmagic added question Further information is requested and removed bug Something isn't working labels Dec 14, 2022
@jipika
Copy link
Author

jipika commented Dec 15, 2022

感觉大佬的解答哇

@jipika jipika closed this as completed Dec 15, 2022
@imaxing
Copy link

imaxing commented Jun 7, 2023

感谢大佬 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants