显示开关
这一节的交互由演示页脚本驱动,效果见右侧实时预览。
过渡容器包住一块内容,按显示状态切换出现与消失。
整目录放进工程即用:easycom 按标签逐个解析,页面写哪个组件就只编译哪个,不写 import,也没有全局注册这一步;单个组件也可以显式引入(第 4 步,可选);主题层在 App.uvue 引入一次即可。
# 1 整目录放进工程(easycom 自动解析) your-project/ └── uni_modules/ └── colorui-x/ # 2 App.uvue 全局引入主题层(一次) @import 'uni_modules/colorui-x/theme/base.css'; @import 'uni_modules/colorui-x/theme/layout.css'; @import 'uni_modules/colorui-x/theme/color.scss'; // 颜色工具类(.bg-* / .text-*) # 3 页面里直接用,不写 import(只编译用到的组件) <cu-transition /> # 4 单个组件也可以显式引入(可选,不用 easycom 时) import CuTransition from '@/uni_modules/colorui-x/components/cu-transition/cu-transition.uvue'
组件样式自包含(只依赖包内 token.scss),主题层是给页面工具类用的,不参与组件注册。两种安装方式见 快速上手。
| Android | iOS | HarmonyOS | Web(H5) | 微信小程序 | 支付宝小程序 |
|---|---|---|---|---|---|
| √ | — | — | √ | — | — |
Android 列取自本仓真机逐屏判定(√ 已验 / — 待复核 / × 已登记缺陷,本件当前为「真机已验」)。
Web 列只表示已编出可运行的预览产物,非真机渲染。
其余三端没有任何实测证据,不作支持承诺。
这一节的交互由演示页脚本驱动,效果见右侧实时预览。
<cu-transition :show="show" mode="fade"> <text> fade </text> </cu-transition> <cu-transition :show="show" mode="zoom"> <text> zoom </text> </cu-transition> <cu-transition :show="show" mode="fade-zoom"> <text> fade-zoom </text> </cu-transition> <cu-transition :show="show" mode="fade-up"> <text> fade-up </text> </cu-transition> <cu-transition :show="show" mode="fade-down"> <text> fade-down </text> </cu-transition> <cu-transition :show="show" mode="fade-left"> <text> fade-left </text> </cu-transition> <cu-transition :show="show" mode="fade-right"> <text> fade-right </text> </cu-transition> <cu-transition :show="show" mode="slide-up"> <text> slide-up </text> </cu-transition> <cu-transition :show="show" mode="slide-down"> <text> slide-down </text> </cu-transition> <cu-transition :show="show" mode="slide-left"> <text> slide-left </text> </cu-transition> <cu-transition :show="show" mode="slide-right"> <text> slide-right </text> </cu-transition>
<cu-transition :show="show" mode="rotate"> <text> mode=rotate </text> </cu-transition>
<cu-transition :show="show"> <text> 默认 mode </text> </cu-transition> <cu-transition :show="false" mode="slide-up"> <text> 不该出现 </text> </cu-transition>
<cu-transition :show="show" mode="fade-down"> <text> 这是一段放进动画容器默认槽里的超长文案,超长文案继续重复以触发换行,用来确认 cu-transition 只做类名切换、不改变内容的盒模型与换行行为;容器本身没有任何尺寸约束,宽高完全由内部内容决定。 </text> </cu-transition>
<cu-transition :show="show" mode="fade" :duration="1000" timingFunction="linear"> <text> duration=1000 </text> </cu-transition>
这一节的交互由演示页脚本驱动,效果见右侧实时预览。
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| 显示 | |||
| show | 是否显示内容 | Boolean | false |
| mode | fade / zoom / fade-up / slide-up 等 11 档动画名 | String | 'fade' |
| 交互与样式 | |||
| customStyle | 根节点内联样式 | Object | (): UTSJSONObject => ({}) |
| customClass | 追加到根节点的类名 | String | '' |
| 声明保留但不被消费 | |||
| duration | 动画时长;动画层未移植,传了不生效 | Number | 300 |
| timingFunction | 缓动曲线;同上不生效 | String | 'ease-out' |
| url | 不产生跳转 | String | '' |
| linkType | 不产生跳转,同上 | String | 'navigateTo' |
| 事件 | 说明 | 类型 | 默认值 | 平台差异说明 |
|---|---|---|---|---|
| @click | 点击内容时触发,无载荷 | Handler | - | 各端一致 |
| slot | 说明 |
|---|---|
| (默认) | 被包裹的内容 |
13 · 暂无过渡动画 :动画层未移植,显示与隐藏为直切;6 条生命周期事件也不触发。
mode 映射 :11 档动画名映射到动画类;非法值不加类,只做直切。