Skip to content

暗黑模式 ​

如何使用 ​

只需要在 main.ts 中配置 theme 为 dark 即可。

typescript
import kswUx from '@ksware/ksw-ux';


app.use(kswUx, {
  theme: 'dark'
});

动态切换 ​

组件库导出了 toggleTheme 方法,可以通过该方法动态切换主题。

vue
<template>
  <div>
    <k-button @click="toggleTheme">切换主题</k-button>
  </div>
</template>
typescript
import { setTheme, toggleTheme, getCurrentTheme } from '@ksware/ksw-ux';

提示

除了 toggleTheme 方法,组件库还提供了以下方法用于灵活适配。

  • setTheme:用于设置主题,接受 theme 参数,值为 'light' 或 'dark'。
  • getCurrentTheme:用于获取当前主题,返回值为 'light' 或 'dark'。