[Bug report] unocss使用@apply产生异常
@cwyyue is already working on this.
Since Aug 6, 2025.
Assessment
This issue has not been assessed yet.
Description
问题描述
请用简洁的语言描述你遇到的bug,至少包括以下部分,如提供截图请尽量完整:
- 问题触发的条件
在style标签里面使用@apply,编译后的wxss文件只会生成@apply最后一个样式。 - 期望的表现
比如@apply text-red-1 bg-white; - 实际的表现
只会生成background-color: white;
环境信息描述
至少包含以下部分:
- 系统类型(Mac或者Windows)
windows和mac都一样 - Mpx依赖版本(@mpxjs/core、@mpxjs/webpack-plugin和@mpxjs/api-proxy的具体版本,可以通过package-lock.json或者实际去node_modules当中查看)
最新版本 - 小程序开发者工具信息(小程序平台、开发者工具版本、基础库版本)
微信、抖音
最简复现demo
<style lang="less"> .list { // --at-apply: bg-red-500; @apply text-gray-1 bg-red-500; // 这里只会生成最后一个css,比如leading-40px .item { @apply text-red-1 bg-white leading-40px; // 如果使用--at-apply,末行会多生成一个分号,导致微信开发工具报错 // --at-apply: text-red-1 bg-white leading-40px; /** [ WXSS 文件编译错误] ./components/list4cb8a88a/index.wxss(10:161): unexpected token `;`(env: Windows,mp,1.06.2505152; lib: 3.8.4) */ } /** ./components/list4cb8a88a/index.wxss(3:3): unexpected `@` at pos 44(env: Windows,mp,1.06.2505152; lib: 3.8.4) */ } </style>仓库地址:https://github.com/liziwork/mpx-windows-easy-demo
请查看components/list组件style部分
- Dominant language
- JavaScript
- Stars
- 3.9k
- Forks
- 392
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 15
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from didi/mpx
-
🌟 案例收集 Open
Difficulty 1/5 Under an hour Newbie friendliness 78/100
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
-
是否有计划适配云闪付小程序 Open
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
[Block] Latest Posts [Type] Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
sugarlabs/musicblocks#8847 ·