usePlatformAttribute #
把平台检测脚本放进页面的 head,这样 CSS 从第一帧起就能显示 ⌘ 或 Ctrl:静态 HTML 不知道访客的平台,等 hydration 之后再换文字会让布局跳一下。
用法 #
TypeScript
import { usePlatformAttribute } from 'kawapress/client'
usePlatformAttribute()注意 #
组件把两种文字都渲染出来,再用 :root[data-kawa-platform='apple'] 隐藏其中一个。在多个组件里调用它,也只会输出一个标签。
完整类型签名
TypeScript
function usePlatformAttribute(): void

评论