01 / Overview
cu-shop-config-provider
页面根部的配置注入点:一次传入语言、货币符号、日期格式与默认图,子级 Shop 组件从共享 store 读取,不需要逐层透传 props。参考实现用 React Context 下发;本仓无 Context,改为组件初始化与 props 变化时写 `store/shop-config.uts`。
通用
8 条 props
0 事件
已实现
02 / Demo
实时预览
演示页:/pages/shop/config-provider。右侧的预览由站点脚本把 H5 演示页装进 iframe;数据与交互在演示页内操作,不在此处留静态截图。
依赖
- 基础件:无
- Shop 共享件:
store/shop-config.uts、locale/index.uts(语言切换另用colorui-x/store/locale.uts) - 实体:不消费业务实体
03 / Props · Events · Slots
全量契约
props
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| locale | 语言标识(zh-Hans / en);空串不切换当前语言 | string | '' |
| currencySymbol | 货币符号,写入 shopCurrencySymbol | string | '¥' |
| dateFormat | 日期显示格式,写入 shopDateFormat | string | 'YYYY-MM-DD HH:mm' |
| defaultImage | 无图时的默认占位 URL,写入 shopDefaultImage | string | '' |
| customStyle | 根节点自定义样式 | Object | {} |
| customClass | 根节点自定义类名 | string | '' |
| url | 透传字段,本件未接线 | string | '' |
| linkType | 透传字段,本件未接线 | string | 'navigateTo' |
events
本件不派发事件。
slots
| 插槽 | 作用域 | 说明 |
|---|---|---|
| default | 无 | 业务内容 |
04 / Example
代码示例
<cu-shop-config-provider locale="zh-Hans" currencySymbol="¥" dateFormat="YYYY-MM-DD HH:mm">
<view>业务内容</view>
</cu-shop-config-provider>
05 / Notes
注意事项
仅向下注入语言、货币符号、日期格式、默认图四项配置,不渲染业务内容(只提供一个默认插槽)
不请求接口、不自行读写 storage;三组展示配置只存在内存 store
不校验语言码:locale 原样交给 colorui-x cuSetLocale,无法识别的码保持当前语言(该函数的既有 storage 行为不变)
需放在页面根部包住业务内容,子级组件从 store/shop-config.uts 与 locale/index.uts 读取
安装 colorui-shop 全量包与安装任意 cu-shop-* 单件包二选一,不要同时装。单件包的前提是已安装完整 colorui-x。