Files
workspace/code/g3soft-libs/docs/examples/button/global-defaults.vue
T
2026-10-09 22:05:02 +08:00

22 lines
775 B
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
// 全局默认值:显式 prop > componentDefaults > 组件内置默认
import { G3Button, G3ConfigProvider, G3Space } from '@g3soft/ui'
</script>
<template>
<G3Space vertical :size="12" style="display: flex">
<!-- 默认:primary / medium -->
<G3Space :size="8">
<G3Button>默认变体</G3Button>
</G3Space>
<!-- 子树内所有按钮默认变成 outline / small,显式传 type 仍然优先 -->
<G3ConfigProvider :component-defaults="{ button: { type: 'outline', size: 'small' } }">
<G3Space :size="8" align="center">
<G3Button>继承全局默认</G3Button>
<G3Button type="primary" size="large">显式 prop 优先</G3Button>
</G3Space>
</G3ConfigProvider>
</G3Space>
</template>