微信小程序 Skyline 基础组件支持与差异

通用特性

特性 支持情况
无障碍访问 暂时只支持 aria-role、label、hidden、disabled
深色模式 支持
原生组件 都支持同层渲染
WeUI v2 支持

组件支持情况

总体来说,常用的组件基本都已经支持,已经标记为废弃的特性在 Skyline 下不会考虑支持。下面列出基础组件的整体情况,具体细节可以跳转到对应组件文档查看。

组件
支持情况 组件差异与备注
text 基本支持 内联文本只能用 text 组件;可以通过 span 组件与 text 或 image 内联;
view / cover-view 完全支持 涉及文本节点请参考 text 组件
image / cover-image 基本支持 SVG 支持度已经完善;部分不常用的 mode 未支持
button 完全支持
scroll-view 完全支持 需要显式指定 type="list";部分属性不需要对齐;额外支持大量新特性
swiper / swiper-item 完全支持 增强了大量特性
input / textarea 完全支持 光标选区、菜单略有不同
navigator 完全支持 只能嵌套 text 组件或文本节点;可以通过 span 组件与 text 或 image 内联
map 完全支持 开发者工具暂时不支持调试,请使用真机预览
canvas 完全支持 开发者工具暂时不支持调试,请使用真机预览
radio / radio-group 完全支持
label 完全支持
video 基本支持 全屏在 3.3.0 版本已经支持,投屏暂时不支持,开发者工具暂时不支持调试,请使用真机预览
checkbox / checkbox-group 完全支持
picker 完全支持
camera 完全支持 开发者工具暂时不支持调试,请使用真机预览
root-portal 完全支持
form 完全支持
ad 完全支持
official-account 完全支持
functional-page-navigator 支持中
live-player / live-pusher 完全支持
picker-view 基本支持 indicator-class 和 mask-style 属性暂时不支持
voip-room 完全支持
rich-text 完全支持 渲染结果可能略有不同,涉及到样式支持度;当 mode=web 时则完全与 webview 对齐
match-media 待考虑
keyboard-accessary 待考虑 可以通过 input 的 worklet:onkeyboardheightchange 回调实现
page-meta 基本支持 与全局滚动相关的属性不支持
editor 暂不考虑
web-view 暂不考虑 建议承载 web-view 的页面单独配置 "renderer": "webview"
movable-area / movable-view 暂不考虑 可以用手势配合 worklet 动画方案替代
page-container 基本支持
share-element 完全支持 与 WebView 使用方式不同,特性有所增强
icon 完全支持
progress 暂不考虑
slider 完全支持
switch 完全支持
xr-frame 暂未支持
navigation-bar 不考虑 Skyline 只能用自定义导航
open-data 完全支持 已废弃的特性不支持

Skyline 新增组件

组件
组件说明
span 用于支持内联文本和 image、navigator 的混排
snapshot 截图组件
sticky-header、sticky-section 吸顶布局容器
nested-scroll-header、nested-scroll-body 嵌套 scroll-view 场景中使用的节点,仅支持作为 <scroll-view type="nested"> 模式的直接子节点
list-view 列表布局容器,仅支持作为 <scroll-view type="custom"> 模式的直接子节点或 sticky-section 组件的直接子节点
grid-view Skyline 下的网格布局容器和瀑布流布局容器
draggable-sheet 半屏可拖拽组件
double-tap-gesture-handler 双击时触发手势
force-press-gesture-handler iPhone 设备重按时触发手势
horizontal-drag-gesture-handler 横向滑动时触发手势
long-press-gesture-handler 长按时触发手势
pan-gesture-handler 拖动(横向或纵向)时触发手势
scale-gesture-handler 多指缩放时触发手势
tap-gesture-handler 点击时触发手势
vertical-drag-gesture-handler 纵向滑动时触发手势

Skyline WXSS 样式支持与差异

模块支持

模块 支持情况 备注
CSS Animation 安卓 8.0.37,iOS 8.0.39,支持情况见下表
背景与边框 常用的基本支持,详见属性支持
盒子模型 支持 border-box 和 content-box,没有 BFC
Inline 布局 × 开发中
Inline-Block 布局 × 仅支持在 text 组件里的嵌套结构使用,完整版本开发中
Block 布局 详见开启默认 Block 布局
Flex 布局 包括 inline-flex 布局
字体 基本支持,也支持自定义字体
Positioned 布局 支持情况见下表。sticky 可使用 sticky-header/sticky-section 替代
CSS Transition
CSS Variable(CSS 变量) 安卓 8.0.35,iOS 8.0.38
Media queries 只支持 DarkMode
Font-face 只支持 ttf 格式

选择器支持

类别 示例 支持度 备注
通配选择器 * {} ×
元素选择器 tag {}
类选择器 .class {}
ID 选择器 #id {}
分组选择器 a, b {}
直接子代选择器 a > b {}
后代选择器 a b {}
属性选择器 [attr] {} ×
一般兄弟选择器 a ~ b {} 8.0.49
紧邻兄弟选择器 a + b {} 8.0.49
伪类选择器 :active {} 支持 :first-child / :last-child;微信 8.0.49 起(对应 Skyline 1.3.0)支持 :not / :only-child / :empty;微信 8.0.50 起(对应 Skyline 1.3.3)支持 :nth-child
伪元素选择器 ::before {} 只支持 ::before 和 ::after

属性支持

样式属性 支持格式 默认值 备注
display none / flex / block flex 默认值可通过配置改成 block
position relative / absolute / fixed relative fixed 在微信客户端 8.0.43 版本开始支持,只支持相对于窗口 viewport 定位,不支持 top / left / bottom / right 默认值 auto 解析,z-index 只作用在兄弟节点;sticky 可使用 sticky-header/sticky-section 替代
overflow hidden / visible visible scroll 不支持,只能通过 scroll-view 实现;不支持单独设置 overflow-x/y
pointer-events auto / none auto
box-sizing border-box / content-box border-box
transform none / <transform-function> none
transform-origin left / center / right / top / bottom / {1, 2} 50% 50%
z-index <float> 0 不支持层叠上下文,只对兄弟节点生效;不支持在 scroll-view 下的直接子节点上应用
visibility visible / hidden visible
color black
opacity <float> 1
align-items stretch / center / flex-start / flex-end / baseline stretch
align-self auto / stretch / center / flex-start / flex-end / baseline auto
align-content stretch / center / flex-start / flex-end / space-between / space-around auto
justify-content center / flex-start / flex-end / space-between / space-around / space-evenly flex-start
flex-direction row / row-reverse / column / column-reverse column
flex-wrap nowrap / wrap / wrap-reverse nowrap
flex-grow <float> 0
flex-shrink <float> 1
flex-basis auto
order <float> 0
gap <length> 0
flex 简写属性,支持解析但以展开属性为准
background-color transparent
background-image none / none 不支持多张图片
background-size contain / cover / [ | auto]{1, 2} auto
background-position left / center / right / top / bottom / 0 0 完全支持 <bg-position>#,请参考 MDN
background-repeat repeat-x / repeat-y / repeat / no-repeat repeat
background 简写属性,支持解析但以展开属性为准
width auto
height auto
min-width auto
min-height none
max-width auto
max-height none
left auto
right auto
top auto
bottom auto
padding {1,4} 0 0 0 0
padding-left 0
padding-top 0
padding-right 0
padding-bottom 0
margin {1,4} 0 0 0 0
margin-left 0
margin-top 0
margin-right 0
margin-bottom 0
border-left-width 3
border-left-style none
border-left-color black 默认值与网页不同,网页默认值是 currentcolor
border-top-width 3
border-top-style none
border-top-color black 默认值与网页不同,网页默认值是 currentcolor
border-right-width 3
border-right-style none
border-right-color black 默认值与网页不同,网页默认值是 currentcolor
border-bottom-width 3
border-bottom-style none
border-bottom-color black 默认值与网页不同,网页默认值是 currentcolor
border-width 简写属性,支持解析但以展开属性为准
border-style 简写属性,支持解析但以展开属性为准
border-color 简写属性,支持解析但以展开属性为准
border-left 简写属性,支持解析但以展开属性为准
border-right 简写属性,支持解析但以展开属性为准
border-top 简写属性,支持解析但以展开属性为准
border-bottom 简写属性,支持解析但以展开属性为准
border 简写属性,支持解析但以展开属性为准
box-shadow none / inset? && {2,4} && ? none 不支持多个叠加
border-top-left-radius {1, 2} 0 当 border-radius 不为 0 时,四边的 border-width 可以不一样,但四边的 border-color 和 border-style 必须一致
border-top-right-radius {1, 2} 0 当 border-radius 不为 0 时,四边的 border-width 可以不一样,但四边的 border-color 和 border-style 必须一致
border-bottom-left-radius {1, 2} 0 当 border-radius 不为 0 时,四边的 border-width 可以不一样,但四边的 border-color 和 border-style 必须一致
border-bottom-right-radius {1, 2} 0 当 border-radius 不为 0 时,四边的 border-width 可以不一样,但四边的 border-color 和 border-style 必须一致
border-radius 简写属性,支持解析但以展开属性为准
transition-property none / all / transform / opacity 等 all 基本都支持,暂不一一列举
transition-duration <time> 0
transition-timing-function
transition-delay <time> 0
transition 简写属性,支持解析但以展开属性为准
font 简写属性,支持解析但以展开属性为准;不支持 caption / icon 等系统字体;
font-size 16px 不支持百分比;不支持 keyword(如 smaller 等)
line-height normal / <number> / / <percent> normal
text-align left / center / right / justify / start / end start
font-weight normal / bold / <float> normal
white-space normal / nowrap / normal
text-overflow clip / ellipsis clip 仅作用于文本节点
word-break normal / break-all normal
word-spacing normal / normal
letter-spacing normal / normal
font-family serif / sans-serif / monospace / cursive / fantasy / <string>
font-style normal / italic normal
text-decoration-line none / underline / overline / line-through none 仅作用于文本节点
text-decoration-style solid / double / dotted / dashed / wavy solid 仅作用于文本节点
text-decoration-color black 仅作用于文本节点;默认值和网页不同,网页默认值是 currentcolor
text-decoration 简写属性,支持解析但以展开属性为准;当前仅支持设置一种类型;暂不支持复合使用 text-decoration
text-shadow none / ? && {2,3} none
backdrop-filter none / [] none 不支持多个函数;不支持 drop-shadow;不支持 url;与 opacity 混合时有问题;blur 在某些情况下表现不一致;
filter none / [] none 不支持多个函数;不支持 drop-shadow;不支持 url;
mask-image none / none 不支持多张图片
animation-delay <time> 0
animation-direction normal / reverse / alternate / alternate-reverse normal
animation-duration <time> 0
animation-fill-mode forwards / both none none 和 backwards 暂时不支持,表现都等同于 forwards
animation-iteration-count infinite / <number> 1
animation-name none / <custom-ident> none
animation-timing-function
animation 简写属性,支持解析但以展开属性为准
will-change auto / contents auto 声明绘制边界,优化渲染性能

类型支持列表

类别 格式 支持度 备注
auto
px
rem
em ×
rpx
vw
vh
vmin
vmax
ratio
env() 只支持 safe-area-inset-* 系列
calc()
color keywords
transparent
currentColor × 考虑支持
rgb[a]
#RRGGBB / #RGB
hsl
hsla
url()
linear-gradient()
radial-gradient()
conic-gradient()
none
hidden
solid
dashed
dotted
brightness() 多个函数暂时不支持
contrast()
saturate()
huerotate()
invert()
opacity()
grayscale()
specia()
drop-shadow ×
deg
grad
rad
turn
ease
ease-in
ease-out
ease-in-out
linear
cubic-bezier
steps
step-start
step-end

开启默认Block布局

在微信小程序的 Skyline 渲染模式下,节点默认使用 flex 布局。你可以通过以下配置,将其切换为默认的 block 布局。

平台 最低版本
Android 8.0.34
IOS 8.0.36
开发者工具 Nightly Build (1.06.2304262)
基础库 2.31.1

app.jsonpage.json 中配置:

rendererOptions: {
  "skyline": {
    "defaultDisplayBlock": true,
  }
}

开启默认ContentBox盒模型

在微信小程序的 Skyline 渲染模式下,节点默认使用 border-box 盒模型。你可以通过以下配置,将其切换为默认的 content-box 盒模型。

平台 最低版本
Android 8.0.42
IOS 8.0.42
开发者工具 Nightly Build (1.06.2310092)
基础库 3.1.0

app.jsonpage.json 中配置:

rendererOptions: {
  "skyline": {
    "defaultContentBox": true,
  }
}

开启tag选择器全局匹配

在微信小程序的 Skyline 渲染模式下,tag 选择器会遵循样式隔离机制,而 WebView 模式下则不受此约束。你可以通过配置 tagNameStyleIsolation: legacy 来对齐 WebView 的表现。如果指定 tagNameStyleIsolation: isolated,则会遵循样式隔离机制。

平台 最低版本
Android 8.0.51
IOS 8.0.51
开发者工具 Nightly Build (1.06.2409032)
基础库 3.6.0

app.jsonpage.json 中配置:

rendererOptions: {
  "skyline": {
    "tagNameStyleIsolation": "legacy",
  }
}

开启scroll-view自动撑开

在微信小程序的 Skyline 渲染模式下,scroll-view 默认需要指定宽高才能撑开。你可以通过以下配置,将其切换为根据内容自动撑开。

平台 最低版本
Android 8.0.54
IOS 8.0.54
基础库 3.7.2

app.jsonpage.json 中配置:

rendererOptions: {
  "skyline": {
    "enableScrollViewAutoSize": true,
  }
}

开启keyframe样式全局共享

微信小程序的 Skyline 渲染模式下,@keyframe 规则会遵循样式隔离机制,而 WebView 模式下则不受此约束。你可以通过配置 tagNameStyleIsolation: legacy 来对齐 WebView 的表现。如果指定 tagNameStyleIsolation: isolated,则会遵循样式隔离机制。

平台 最低版本
Android 8.0.57
IOS 8.0.57
基础库 3.8.0

app.jsonpage.json 中配置:

rendererOptions: {
  "skyline": {
    "keyframeStyleIsolation": "legacy",
  }
}