x-next 1.13.0 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AI_CODING.md +6 -5
- package/AI_USAGE/catalog.md +108 -105
- package/AI_USAGE/components/alert-api.md +48 -0
- package/AI_USAGE/components/alert.md +222 -3
- package/AI_USAGE/components/bar-chart-api.md +177 -0
- package/AI_USAGE/components/bar-chart.md +297 -3
- package/AI_USAGE/components/boxicons.md +147 -0
- package/AI_USAGE/components/button-api.md +144 -0
- package/AI_USAGE/components/button.md +447 -3
- package/AI_USAGE/components/charts.md +81 -0
- package/AI_USAGE/components/checkbox-api.md +145 -0
- package/AI_USAGE/components/checkbox.md +365 -3
- package/AI_USAGE/components/color-picker-api.md +52 -0
- package/AI_USAGE/components/color-picker.md +211 -3
- package/AI_USAGE/components/config-provider-api.md +38 -0
- package/AI_USAGE/components/config-provider.md +250 -3
- package/AI_USAGE/components/date-picker-api.md +1114 -0
- package/AI_USAGE/components/date-picker.md +378 -3
- package/AI_USAGE/components/dialog-api.md +142 -0
- package/AI_USAGE/components/dialog.md +284 -3
- package/AI_USAGE/components/draggable-api.md +146 -0
- package/AI_USAGE/components/draggable.md +259 -0
- package/AI_USAGE/components/drawer-api.md +78 -0
- package/AI_USAGE/components/drawer.md +256 -0
- package/AI_USAGE/components/dropdown-api.md +529 -0
- package/AI_USAGE/components/dropdown.md +392 -3
- package/AI_USAGE/components/empty-api.md +36 -0
- package/AI_USAGE/components/empty.md +227 -3
- package/AI_USAGE/components/finicon.md +88 -0
- package/AI_USAGE/components/form-api.md +524 -0
- package/AI_USAGE/components/form.md +454 -0
- package/AI_USAGE/components/grid-api.md +527 -0
- package/AI_USAGE/components/grid.md +224 -0
- package/AI_USAGE/components/heatmap-api.md +122 -0
- package/AI_USAGE/components/heatmap.md +220 -0
- package/AI_USAGE/components/icon-api.md +4707 -0
- package/AI_USAGE/components/icon.md +257 -0
- package/AI_USAGE/components/image-api.md +440 -0
- package/AI_USAGE/components/image.md +465 -0
- package/AI_USAGE/components/input-api.md +184 -0
- package/AI_USAGE/components/input-number-api.md +66 -0
- package/AI_USAGE/components/input-number.md +294 -0
- package/AI_USAGE/components/input-tag-api.md +114 -0
- package/AI_USAGE/components/input-tag.md +482 -0
- package/AI_USAGE/components/input.md +293 -3
- package/AI_USAGE/components/layout-api.md +147 -0
- package/AI_USAGE/components/layout.md +230 -0
- package/AI_USAGE/components/line-chart-api.md +197 -0
- package/AI_USAGE/components/line-chart.md +306 -3
- package/AI_USAGE/components/link-api.md +42 -0
- package/AI_USAGE/components/link.md +197 -0
- package/AI_USAGE/components/menu-api.md +516 -0
- package/AI_USAGE/components/menu.md +268 -0
- package/AI_USAGE/components/message-api.md +215 -0
- package/AI_USAGE/components/message-box-api.md +108 -0
- package/AI_USAGE/components/message-box.md +268 -3
- package/AI_USAGE/components/message.md +231 -3
- package/AI_USAGE/components/network-api.md +91 -0
- package/AI_USAGE/components/network.md +378 -0
- package/AI_USAGE/components/notification-api.md +236 -0
- package/AI_USAGE/components/notification.md +275 -3
- package/AI_USAGE/components/pagination-api.md +62 -0
- package/AI_USAGE/components/pagination.md +380 -3
- package/AI_USAGE/components/pie-chart-api.md +109 -0
- package/AI_USAGE/components/pie-chart.md +245 -3
- package/AI_USAGE/components/popconfirm-api.md +75 -0
- package/AI_USAGE/components/popconfirm.md +231 -3
- package/AI_USAGE/components/popover-api.md +75 -0
- package/AI_USAGE/components/popover.md +208 -3
- package/AI_USAGE/components/popup-api.md +75 -0
- package/AI_USAGE/components/popup.md +52 -0
- package/AI_USAGE/components/progress-api.md +44 -0
- package/AI_USAGE/components/progress.md +248 -3
- package/AI_USAGE/components/radio-api.md +165 -0
- package/AI_USAGE/components/radio.md +259 -3
- package/AI_USAGE/components/rate-api.md +54 -0
- package/AI_USAGE/components/rate.md +233 -3
- package/AI_USAGE/components/resize-box-api.md +56 -0
- package/AI_USAGE/components/resize-box.md +231 -0
- package/AI_USAGE/components/scrollbar-api.md +77 -0
- package/AI_USAGE/components/scrollbar.md +218 -0
- package/AI_USAGE/components/select-api.md +758 -0
- package/AI_USAGE/components/select.md +640 -3
- package/AI_USAGE/components/skeleton-api.md +85 -0
- package/AI_USAGE/components/skeleton.md +150 -0
- package/AI_USAGE/components/slider-api.md +51 -0
- package/AI_USAGE/components/slider.md +233 -3
- package/AI_USAGE/components/space-api.md +38 -0
- package/AI_USAGE/components/space.md +145 -0
- package/AI_USAGE/components/spin-api.md +43 -0
- package/AI_USAGE/components/spin.md +205 -0
- package/AI_USAGE/components/steps-api.md +111 -0
- package/AI_USAGE/components/steps.md +201 -3
- package/AI_USAGE/components/switch-api.md +58 -0
- package/AI_USAGE/components/switch.md +290 -3
- package/AI_USAGE/components/table-api.md +2919 -0
- package/AI_USAGE/components/table.md +1457 -0
- package/AI_USAGE/components/tabs-api.md +135 -0
- package/AI_USAGE/components/tabs.md +308 -3
- package/AI_USAGE/components/tag-api.md +124 -0
- package/AI_USAGE/components/tag.md +292 -0
- package/AI_USAGE/components/textarea-api.md +55 -0
- package/AI_USAGE/components/textarea.md +326 -3
- package/AI_USAGE/components/time-picker-api.md +137 -0
- package/AI_USAGE/components/time-picker.md +271 -3
- package/AI_USAGE/components/time-range-selector-api.md +44 -0
- package/AI_USAGE/components/time-range-selector.md +355 -0
- package/AI_USAGE/components/timeline-api.md +93 -0
- package/AI_USAGE/components/timeline.md +312 -0
- package/AI_USAGE/components/tooltip-api.md +77 -0
- package/AI_USAGE/components/tooltip.md +182 -0
- package/AI_USAGE/components/tree-select-api.md +498 -0
- package/AI_USAGE/components/tree-select.md +744 -0
- package/AI_USAGE/components/trend-chart-api.md +119 -0
- package/AI_USAGE/components/trend-chart.md +335 -0
- package/AI_USAGE/components/trigger-api.md +124 -0
- package/AI_USAGE/components/trigger.md +185 -0
- package/AI_USAGE/components/upload-api.md +200 -0
- package/AI_USAGE/components/upload.md +711 -3
- package/AI_USAGE/components/watermark-api.md +87 -0
- package/AI_USAGE/components/watermark.md +200 -0
- package/AI_USAGE/core.md +1 -1
- package/AI_USAGE/index.md +36 -7
- package/AI_USAGE/recipes/form-on-demand.md +1 -1
- package/AI_USAGE.md +34972 -5
- package/CHANGELOG.md +39 -0
- package/dist/_props/css.d.ts +2 -1
- package/dist/_utils/inherit-component-type.d.ts +11 -0
- package/dist/components/bar-chart/BarChart.d.ts +1 -1
- package/dist/components/bar-chart/index.d.ts +3 -3
- package/dist/components/date-picker/index.d.ts +420 -5
- package/dist/components/form-input/index.d.ts +617 -2
- package/dist/components/index.d.ts +1 -0
- package/dist/components/layout/index.d.ts +689 -1
- package/dist/components/line-chart/LineChart.d.ts +1 -1
- package/dist/components/line-chart/index.d.ts +3 -3
- package/dist/components/line-chart/interface.d.ts +2 -2
- package/dist/components/menu/index.d.ts +786 -1
- package/dist/components/tree-select/TreeNode.vue.d.ts +478 -0
- package/dist/components/tree-select/TreeSelect.d.ts +1549 -0
- package/dist/components/tree-select/TreeSelectDropdown.vue.d.ts +569 -0
- package/dist/components/tree-select/hooks/use-tree-select.d.ts +92 -0
- package/dist/components/tree-select/index.d.ts +3321 -0
- package/dist/components/tree-select/interface.d.ts +203 -0
- package/dist/components/tree-select/utils.d.ts +64 -0
- package/dist/es/_styles/palette-aliases.js +3 -0
- package/dist/es/_utils/inherit-component-type.js +6 -0
- package/dist/es/components/_components/feedback-icon/index.vue2.js +10 -10
- package/dist/es/components/button/Button.js +9 -9
- package/dist/es/components/date-picker/index.js +18 -17
- package/dist/es/components/drawer/src/Drawer.vue.js +6 -6
- package/dist/es/components/form-input/index.js +12 -11
- package/dist/es/components/form-switch/Switch.vue2.js +18 -18
- package/dist/es/components/image/Image.vue2.js +13 -13
- package/dist/es/components/image/ImagePreview.vue2.js +33 -33
- package/dist/es/components/index.js +55 -52
- package/dist/es/components/layout/index.js +10 -9
- package/dist/es/components/link/Link.vue2.js +12 -12
- package/dist/es/components/menu/hooks/use-level.js +5 -5
- package/dist/es/components/menu/index.js +13 -10
- package/dist/es/components/message/message.vue2.js +13 -13
- package/dist/es/components/spin/Spin.js +28 -28
- package/dist/es/components/tag/Tag.vue2.js +22 -22
- package/dist/es/components/timeline/src/Timeline.js +7 -7
- package/dist/es/components/tree-select/TreeNode.vue.js +91 -0
- package/dist/es/components/tree-select/TreeNode.vue2.js +162 -0
- package/dist/es/components/tree-select/TreeSelect.js +865 -0
- package/dist/es/components/tree-select/TreeSelectDropdown.vue.js +57 -0
- package/dist/es/components/tree-select/TreeSelectDropdown.vue2.js +79 -0
- package/dist/es/components/tree-select/hooks/use-tree-select.js +376 -0
- package/dist/es/components/tree-select/index.js +13 -0
- package/dist/es/components/tree-select/utils.js +181 -0
- package/dist/es/icons/animation/animation-loading.js +2 -2
- package/dist/es/index.js +71 -68
- package/dist/es/style.css +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.umd.js +3 -3
- package/dist/style/base.css +1 -1
- package/dist/style/dependencies.json +10 -0
- package/dist/style/drawer.css +1 -1
- package/dist/style/table.css +1 -1
- package/dist/style/tree-select.css +1 -0
- package/dist/style/tree-select.js +8 -0
- package/dist/style.css +1 -1
- package/dist/types.d.ts +2 -0
- package/package.json +11 -5
- package/volar.d.ts +2 -0
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
<!-- Generated by pnpm generate:ai-usage. Edit script/ai-usage/content.md and script/ai-usage/. -->
|
|
2
2
|
# Input AI 使用
|
|
3
3
|
|
|
4
|
-
适用版本:x-next@1.
|
|
4
|
+
适用版本:x-next@1.15.0;来源指纹:`47ea153587c8d0b3bf318977b10bde9f8dd4acff90c5818541ba6513252ad362`。
|
|
5
5
|
|
|
6
|
-
先读 [通用接入](../core.md)。公开导出:`Input
|
|
6
|
+
先读 [通用接入](../core.md)。公开导出:`Input, InputGroup, InputPassword, InputSearch`;主要模型:v-model。完整 Props、Events、Slots、实例方法与服务签名见 [本地 API](./input-api.md),包含本组件族全部子组件和别名。
|
|
7
7
|
|
|
8
8
|
按需样式:`x-next/style/form-input`(包含 base.css、button.css、form-input.css)。代码块未单独引样式时在应用入口加载全量样式,或按实际所有组件加载 JS 入口;不要仅因复制一个组件页就漏掉其中的 Button 等组合依赖。
|
|
9
9
|
|
|
10
|
+
## 已核验行为与示例
|
|
11
|
+
|
|
10
12
|
[组件文档与 live demo](https://x-next.yjmf.com/components/input)。`v-model` 为字符串,`input` 随输入触发;失焦、回车或清空时,值相对聚焦时/上次 change 的记录发生变化才触发 `change(value, event)`。`clear(event)` 通知清空按钮操作;readonly 是组件 prop。原生 id、name、aria、required 用 `inputAttrs`,外部 class / style 落在容器。内部装饰用 prefix / suffix,外侧标签用 prepend / append。
|
|
11
13
|
|
|
12
14
|
```vue
|
|
@@ -29,4 +31,292 @@ const nativeAttrs = { id: 'article-title', name: 'title', 'aria-label': '文章
|
|
|
29
31
|
</template>
|
|
30
32
|
```
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
## 场景用法
|
|
35
|
+
|
|
36
|
+
以下示例从本地 `src/docs/components/input.md` 显式导入到独立 AI 源,补齐局部注册、状态和样式后进行严格模板检查。上方已核验行为优先;原始 prop 默认值、包装透传和示例业务适配分别查 [完整 API](./input-api.md) 与场景说明。类型通过不代表所有散文和交互已验证。
|
|
37
|
+
|
|
38
|
+
### 用途与选型
|
|
39
|
+
|
|
40
|
+
用于单行文本输入,并提供搜索、密码和组合输入等扩展形态。
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### 基础用法
|
|
44
|
+
|
|
45
|
+
```vue
|
|
46
|
+
<script setup lang="ts">
|
|
47
|
+
import 'x-next/style.css';
|
|
48
|
+
import { Input } from 'x-next';
|
|
49
|
+
import { ref } from 'vue';
|
|
50
|
+
|
|
51
|
+
const value = ref('');
|
|
52
|
+
</script>
|
|
53
|
+
<template>
|
|
54
|
+
<Input v-model="value" placeholder="请输入" allow-clear />
|
|
55
|
+
</template>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 前缀与后缀
|
|
59
|
+
|
|
60
|
+
```vue
|
|
61
|
+
<script setup lang="ts">
|
|
62
|
+
import 'x-next/style.css';
|
|
63
|
+
import { Input } from 'x-next';
|
|
64
|
+
import { ref } from 'vue';
|
|
65
|
+
|
|
66
|
+
const value = ref('');
|
|
67
|
+
</script>
|
|
68
|
+
<template>
|
|
69
|
+
<Input v-model="value" placeholder="请输入">
|
|
70
|
+
<template #prefix>https://</template>
|
|
71
|
+
<template #suffix>.com</template>
|
|
72
|
+
</Input>
|
|
73
|
+
</template>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 尺寸
|
|
77
|
+
|
|
78
|
+
```vue
|
|
79
|
+
<script setup lang="ts">
|
|
80
|
+
import 'x-next/style.css';
|
|
81
|
+
import { Input } from 'x-next';
|
|
82
|
+
import { ref } from 'vue';
|
|
83
|
+
const value = ref('当前内容');
|
|
84
|
+
</script>
|
|
85
|
+
<template>
|
|
86
|
+
<Input v-model="value" size="mini" />
|
|
87
|
+
<Input v-model="value" size="small" />
|
|
88
|
+
<Input v-model="value" size="medium" />
|
|
89
|
+
<Input v-model="value" size="large" />
|
|
90
|
+
</template>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 禁用、只读和错误
|
|
94
|
+
|
|
95
|
+
```vue
|
|
96
|
+
<script setup lang="ts">
|
|
97
|
+
import 'x-next/style.css';
|
|
98
|
+
import { Input } from 'x-next';
|
|
99
|
+
import { ref } from 'vue';
|
|
100
|
+
const value = ref('当前内容');
|
|
101
|
+
import type { InputHTMLAttributes } from 'vue';
|
|
102
|
+
const nativeAttrs1 = { "aria-label": "禁用输入" } satisfies InputHTMLAttributes;
|
|
103
|
+
const nativeAttrs2 = { "aria-label": "只读输入" } satisfies InputHTMLAttributes;
|
|
104
|
+
const nativeAttrs3 = { "aria-label": "错误输入" } satisfies InputHTMLAttributes;
|
|
105
|
+
</script>
|
|
106
|
+
<template>
|
|
107
|
+
<Input :input-attrs="nativeAttrs1" v-model="value" disabled allow-clear />
|
|
108
|
+
<Input :input-attrs="nativeAttrs2" v-model="value" readonly allow-clear />
|
|
109
|
+
<Input :input-attrs="nativeAttrs3" v-model="value" error allow-clear />
|
|
110
|
+
</template>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 字数限制
|
|
114
|
+
|
|
115
|
+
`errorOnly` 允许输入超过限制,并展示错误状态。Input 默认按 JavaScript 字符串长度计数;需要自定义计数时,同时提供 `wordLength` 和 `wordSlice`。
|
|
116
|
+
|
|
117
|
+
```vue
|
|
118
|
+
<script setup lang="ts">
|
|
119
|
+
import 'x-next/style.css';
|
|
120
|
+
import { Input } from 'x-next';
|
|
121
|
+
import { ref } from 'vue';
|
|
122
|
+
const value = ref('');
|
|
123
|
+
const overflow = ref('超长内容只提示错误,不会被截断');
|
|
124
|
+
</script>
|
|
125
|
+
<template>
|
|
126
|
+
<Input v-model="value" :max-length="12" show-word-limit allow-clear />
|
|
127
|
+
<Input v-model="overflow" :max-length="{ length: 12, errorOnly: true }" show-word-limit allow-clear />
|
|
128
|
+
</template>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### 搜索、加载和禁用
|
|
132
|
+
|
|
133
|
+
`search` 在点击搜索按钮时触发。需要回车搜索时,可监听继承自 Input 的 `press-enter`,用当前 `v-model` 值执行搜索。禁用状态同时约束输入和搜索按钮,并可继承 Form 的禁用状态与尺寸。
|
|
134
|
+
|
|
135
|
+
```vue
|
|
136
|
+
<script setup lang="ts">
|
|
137
|
+
import 'x-next/style.css';
|
|
138
|
+
import { Checkbox, InputSearch } from 'x-next';
|
|
139
|
+
import { ref } from 'vue';
|
|
140
|
+
const value = ref('');
|
|
141
|
+
const disabled = ref(false);
|
|
142
|
+
const loading = ref(false);
|
|
143
|
+
const result = ref('等待搜索');
|
|
144
|
+
const handleSearch = (value: string) => { result.value = `搜索:${value || '空内容'}`; };
|
|
145
|
+
</script>
|
|
146
|
+
<template>
|
|
147
|
+
<Checkbox v-model="disabled">禁用搜索</Checkbox>
|
|
148
|
+
<Checkbox v-model="loading">加载中</Checkbox>
|
|
149
|
+
<InputSearch v-model="value" :disabled="disabled" :loading="loading" allow-clear @search="handleSearch" />
|
|
150
|
+
<InputSearch v-model="value" :disabled="disabled" :loading="loading" search-button button-text="搜索" @search="handleSearch" />
|
|
151
|
+
<p role="status">{{ result }}</p>
|
|
152
|
+
</template>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### 输入和提交事件
|
|
156
|
+
|
|
157
|
+
`input` 表示键入,`change` 在值有变化时由失焦、回车或清空触发。清空会通知 Form 的 `input` 校验通道,公开事件仍通过 `clear` 表示按钮操作。
|
|
158
|
+
|
|
159
|
+
```vue
|
|
160
|
+
<script setup lang="ts">
|
|
161
|
+
import 'x-next/style.css';
|
|
162
|
+
import { Input } from 'x-next';
|
|
163
|
+
import { ref } from 'vue';
|
|
164
|
+
const value = ref('');
|
|
165
|
+
const result = ref('等待输入');
|
|
166
|
+
</script>
|
|
167
|
+
<template>
|
|
168
|
+
<Input v-model="value" allow-clear
|
|
169
|
+
@input="(next) => result = `input:${next}`"
|
|
170
|
+
@change="(next) => result = `change:${next || '空内容'}`"
|
|
171
|
+
@press-enter="result = `press-enter:${value}`"
|
|
172
|
+
@clear="result = 'clear:已清空'"
|
|
173
|
+
/>
|
|
174
|
+
<p role="status">{{ result }}</p>
|
|
175
|
+
</template>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### 前置与后置标签
|
|
179
|
+
|
|
180
|
+
```vue
|
|
181
|
+
<script setup lang="ts">
|
|
182
|
+
import 'x-next/style.css';
|
|
183
|
+
import { Input } from 'x-next';
|
|
184
|
+
import { ref } from 'vue';
|
|
185
|
+
|
|
186
|
+
const value = ref('');
|
|
187
|
+
</script>
|
|
188
|
+
<template>
|
|
189
|
+
<Input v-model="value" placeholder="请输入域名">
|
|
190
|
+
<template #prepend>https://</template>
|
|
191
|
+
<template #append>.com</template>
|
|
192
|
+
</Input>
|
|
193
|
+
</template>
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### 在 Form 中校验
|
|
197
|
+
|
|
198
|
+
`x-input` 接入 `x-form` 后会自动继承尺寸与禁用状态,并按 `validateTrigger` 触发校验。默认 `change` 表示文本输入在失焦时校验;需要每次输入即校验时设置 `validateTrigger="input"`。
|
|
199
|
+
|
|
200
|
+
```vue
|
|
201
|
+
<script setup lang="ts">
|
|
202
|
+
import 'x-next/style.css';
|
|
203
|
+
import { Form, FormItem, Input, Button } from 'x-next';
|
|
204
|
+
import { reactive, ref } from 'vue';
|
|
205
|
+
import type { FormInstance, FieldRule } from 'x-next';
|
|
206
|
+
|
|
207
|
+
const form = reactive({ email: '', code: '' });
|
|
208
|
+
const formRules: Record<string, FieldRule[]> = {
|
|
209
|
+
email: [
|
|
210
|
+
{ required: true, message: '请输入邮箱' },
|
|
211
|
+
{ type: 'email', message: '邮箱格式不正确' },
|
|
212
|
+
],
|
|
213
|
+
code: [{ required: true, message: '请输入验证码' }],
|
|
214
|
+
};
|
|
215
|
+
const formRef = ref<FormInstance>();
|
|
216
|
+
const formResult = ref('');
|
|
217
|
+
|
|
218
|
+
const onSubmit = async () => {
|
|
219
|
+
const errors = await formRef.value!.validate();
|
|
220
|
+
formResult.value = errors ? '校验失败,请检查表单' : '校验通过,已提交';
|
|
221
|
+
};
|
|
222
|
+
</script>
|
|
223
|
+
<template>
|
|
224
|
+
<Form ref="formRef" :model="form" :rules="formRules">
|
|
225
|
+
<FormItem field="email" label="邮箱">
|
|
226
|
+
<Input v-model="form.email" placeholder="请输入邮箱" allow-clear />
|
|
227
|
+
</FormItem>
|
|
228
|
+
<!-- validate-trigger 是 FormItem 的 prop:每次输入即触发校验 -->
|
|
229
|
+
<FormItem field="code" label="验证码" validate-trigger="input">
|
|
230
|
+
<Input v-model="form.code" placeholder="请输入验证码" />
|
|
231
|
+
</FormItem>
|
|
232
|
+
<FormItem>
|
|
233
|
+
<Button type="primary" @click="onSubmit">提交</Button>
|
|
234
|
+
</FormItem>
|
|
235
|
+
</Form>
|
|
236
|
+
<p role="status">{{ formResult }}</p>
|
|
237
|
+
</template>
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### 关联组件
|
|
241
|
+
|
|
242
|
+
```vue
|
|
243
|
+
<script setup lang="ts">
|
|
244
|
+
import 'x-next/style.css';
|
|
245
|
+
import { InputSearch, InputPassword, InputGroup, Input } from 'x-next';
|
|
246
|
+
import { reactive, ref } from 'vue';
|
|
247
|
+
const password = ref('x-next-password');
|
|
248
|
+
</script>
|
|
249
|
+
<template>
|
|
250
|
+
<InputSearch placeholder="搜索" />
|
|
251
|
+
<InputPassword placeholder="密码" />
|
|
252
|
+
<InputGroup>
|
|
253
|
+
<Input placeholder="省" />
|
|
254
|
+
<Input placeholder="市" />
|
|
255
|
+
</InputGroup>
|
|
256
|
+
</template>
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Select 组合与尺寸
|
|
260
|
+
|
|
261
|
+
Select 可以位于组合的首项或末项。相邻项共享边框,仅组合两端保留圆角;切换尺寸、禁用后,聚焦可检查拼接边框和圆角。
|
|
262
|
+
|
|
263
|
+
```vue
|
|
264
|
+
<script setup lang="ts">
|
|
265
|
+
import 'x-next/style.css';
|
|
266
|
+
import { RadioGroup, Radio, Checkbox, InputGroup, Select, Input, Button } from 'x-next';
|
|
267
|
+
import { ref } from 'vue';
|
|
268
|
+
const size = ref<'mini' | 'small' | 'medium' | 'large'>('medium');
|
|
269
|
+
const disabled = ref(false);
|
|
270
|
+
const value = ref('');
|
|
271
|
+
const type = ref('name');
|
|
272
|
+
const options = [{ label: '名称', value: 'name' }, { label: '编号', value: 'id' }];
|
|
273
|
+
</script>
|
|
274
|
+
<template>
|
|
275
|
+
<RadioGroup v-model="size" type="button">
|
|
276
|
+
<Radio value="mini">mini</Radio>
|
|
277
|
+
<Radio value="small">small</Radio>
|
|
278
|
+
<Radio value="medium">medium</Radio>
|
|
279
|
+
<Radio value="large">large</Radio>
|
|
280
|
+
</RadioGroup>
|
|
281
|
+
<Checkbox v-model="disabled">禁用</Checkbox>
|
|
282
|
+
<InputGroup>
|
|
283
|
+
<Select v-model="type" :options="options" :size="size" :disabled="disabled" style="width: 120px" />
|
|
284
|
+
<Input v-model="value" :size="size" :disabled="disabled" placeholder="选择后输入" />
|
|
285
|
+
<Button :size="size" :disabled="disabled">搜索</Button>
|
|
286
|
+
</InputGroup>
|
|
287
|
+
<InputGroup>
|
|
288
|
+
<Input v-model="value" :size="size" :disabled="disabled" error placeholder="错误态组合" />
|
|
289
|
+
<Select v-model="type" :options="options" :size="size" :disabled="disabled" style="width: 120px" />
|
|
290
|
+
</InputGroup>
|
|
291
|
+
</template>
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### 密码可见性
|
|
295
|
+
|
|
296
|
+
`visibility=true` 表示显示明文,`false` 表示使用密码遮蔽。显隐按钮会触发 `visibility-change` 和 `update:visibility`。
|
|
297
|
+
|
|
298
|
+
非受控密码默认 `defaultVisibility=true`。需要默认遮蔽时设置 `:default-visibility="false"`;禁用时显隐按钮也不可操作。
|
|
299
|
+
|
|
300
|
+
`id`、`name`、`aria-label`、`aria-labelledby`、`aria-describedby`、`inputmode` 等原生属性会传给内部 input;`class` / `style` 保留在组件根节点。也可以通过 `inputAttrs` 集中传入原生属性。
|
|
301
|
+
|
|
302
|
+
```vue
|
|
303
|
+
<script setup lang="ts">
|
|
304
|
+
import 'x-next/style.css';
|
|
305
|
+
import { InputPassword } from 'x-next';
|
|
306
|
+
import { ref } from 'vue';
|
|
307
|
+
|
|
308
|
+
const password = ref('x-next-password');
|
|
309
|
+
const visible = ref(false);
|
|
310
|
+
</script>
|
|
311
|
+
<template>
|
|
312
|
+
<InputPassword
|
|
313
|
+
v-model="password"
|
|
314
|
+
v-model:visibility="visible"
|
|
315
|
+
placeholder="请输入密码"
|
|
316
|
+
/>
|
|
317
|
+
<span>{{ visible ? '明文可见' : '密码已隐藏' }}</span>
|
|
318
|
+
</template>
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
返回 [AI 索引](../index.md)。先查本页与 [本地 API](./input-api.md);需要更深类型时查 [公开组件导航](../catalog.md),不默认上网查找本包用法。
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
<!-- Generated by pnpm generate:ai-usage. Edit script/ai-usage/content.md and script/ai-usage/. -->
|
|
2
|
+
# Layout 完整公开 API
|
|
3
|
+
|
|
4
|
+
适用版本:x-next@1.15.0;来源指纹:`47ea153587c8d0b3bf318977b10bde9f8dd4acff90c5818541ba6513252ad362`。
|
|
5
|
+
|
|
6
|
+
从同版本构建的公开声明、运行时 props/emits 和显式 expose 生成。运行时导入始终使用 `x-next`,声明路径仅作定位。插槽类型未细化时,具体槽名与作用域见本地用法示例。
|
|
7
|
+
|
|
8
|
+
## Layout API
|
|
9
|
+
|
|
10
|
+
公开声明:`dist/components/layout/index.d.ts`。 类型中的 undefined 表示可省略;原始 prop 默认值不等于继承配置或服务默认值。
|
|
11
|
+
|
|
12
|
+
### Props
|
|
13
|
+
|
|
14
|
+
| 名称 | 用途 | 公开类型 | 必填 | 声明默认值 |
|
|
15
|
+
| --- | --- | --- | --- | --- |
|
|
16
|
+
| hasSidebar | 是否包含侧边栏,SSR 场景可用于避免样式闪动 | undefined | false | true | 否 | false(Vue Boolean 转换) |
|
|
17
|
+
|
|
18
|
+
### Events
|
|
19
|
+
|
|
20
|
+
未声明组件 emits;原生事件与包装透传按本页用法核实。
|
|
21
|
+
|
|
22
|
+
### Slots
|
|
23
|
+
|
|
24
|
+
| 名称 | 用途 | 公开类型 |
|
|
25
|
+
| --- | --- | --- |
|
|
26
|
+
| 组件 | 插槽名 | 文档列出的实际插槽;公开类型未细化,作用域见场景用法 |
|
|
27
|
+
| Layout | default | 文档列出的实际插槽;公开类型未细化,作用域见场景用法 |
|
|
28
|
+
| LayoutHeader | default | 文档列出的实际插槽;公开类型未细化,作用域见场景用法 |
|
|
29
|
+
| LayoutContent | default | 文档列出的实际插槽;公开类型未细化,作用域见场景用法 |
|
|
30
|
+
| LayoutFooter | default | 文档列出的实际插槽;公开类型未细化,作用域见场景用法 |
|
|
31
|
+
| LayoutSidebar | default | 文档列出的实际插槽;公开类型未细化,作用域见场景用法 |
|
|
32
|
+
|
|
33
|
+
### 实例方法
|
|
34
|
+
|
|
35
|
+
没有检索到显式 expose 或 Options API methods 的公开方法;不把 setup 内部函数当成稳定实例 API。
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## LayoutContent API
|
|
39
|
+
|
|
40
|
+
公开声明:`dist/components/layout/index.d.ts`。 类型中的 undefined 表示可省略;原始 prop 默认值不等于继承配置或服务默认值。
|
|
41
|
+
|
|
42
|
+
### Props
|
|
43
|
+
|
|
44
|
+
未声明自身 props;包装透传能力见本页用法。
|
|
45
|
+
|
|
46
|
+
### Events
|
|
47
|
+
|
|
48
|
+
未声明组件 emits;原生事件与包装透传按本页用法核实。
|
|
49
|
+
|
|
50
|
+
### Slots
|
|
51
|
+
|
|
52
|
+
公开类型未逐项声明插槽;本页场景说明列出实际使用的插槽,不将任意插槽视为已支持。
|
|
53
|
+
|
|
54
|
+
### 实例方法
|
|
55
|
+
|
|
56
|
+
没有检索到显式 expose 或 Options API methods 的公开方法;不把 setup 内部函数当成稳定实例 API。
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
## LayoutFooter API
|
|
60
|
+
|
|
61
|
+
公开声明:`dist/components/layout/index.d.ts`。 类型中的 undefined 表示可省略;原始 prop 默认值不等于继承配置或服务默认值。
|
|
62
|
+
|
|
63
|
+
### Props
|
|
64
|
+
|
|
65
|
+
未声明自身 props;包装透传能力见本页用法。
|
|
66
|
+
|
|
67
|
+
### Events
|
|
68
|
+
|
|
69
|
+
未声明组件 emits;原生事件与包装透传按本页用法核实。
|
|
70
|
+
|
|
71
|
+
### Slots
|
|
72
|
+
|
|
73
|
+
公开类型未逐项声明插槽;本页场景说明列出实际使用的插槽,不将任意插槽视为已支持。
|
|
74
|
+
|
|
75
|
+
### 实例方法
|
|
76
|
+
|
|
77
|
+
没有检索到显式 expose 或 Options API methods 的公开方法;不把 setup 内部函数当成稳定实例 API。
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
## LayoutHeader API
|
|
81
|
+
|
|
82
|
+
公开声明:`dist/components/layout/index.d.ts`。 类型中的 undefined 表示可省略;原始 prop 默认值不等于继承配置或服务默认值。
|
|
83
|
+
|
|
84
|
+
### Props
|
|
85
|
+
|
|
86
|
+
未声明自身 props;包装透传能力见本页用法。
|
|
87
|
+
|
|
88
|
+
### Events
|
|
89
|
+
|
|
90
|
+
未声明组件 emits;原生事件与包装透传按本页用法核实。
|
|
91
|
+
|
|
92
|
+
### Slots
|
|
93
|
+
|
|
94
|
+
公开类型未逐项声明插槽;本页场景说明列出实际使用的插槽,不将任意插槽视为已支持。
|
|
95
|
+
|
|
96
|
+
### 实例方法
|
|
97
|
+
|
|
98
|
+
没有检索到显式 expose 或 Options API methods 的公开方法;不把 setup 内部函数当成稳定实例 API。
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
## LayoutSidebar API
|
|
102
|
+
|
|
103
|
+
公开声明:`dist/components/layout/index.d.ts`。 类型中的 undefined 表示可省略;原始 prop 默认值不等于继承配置或服务默认值。
|
|
104
|
+
|
|
105
|
+
### Props
|
|
106
|
+
|
|
107
|
+
| 名称 | 用途 | 公开类型 | 必填 | 声明默认值 |
|
|
108
|
+
| --- | --- | --- | --- | --- |
|
|
109
|
+
| theme | 侧边栏主题 | undefined | "dark" | "light" | 否 | "light" |
|
|
110
|
+
| collapsed | 当前收起状态,可配合 v-model:collapsed 使用 | undefined | false | true | 否 | undefined |
|
|
111
|
+
| defaultCollapsed | 默认收起状态,非受控用法 | undefined | false | true | 否 | false(Vue Boolean 转换) |
|
|
112
|
+
| collapsible | 是否可收起 | undefined | false | true | 否 | false(Vue Boolean 转换) |
|
|
113
|
+
| width | 展开宽度 | undefined | string | number | 否 | 200 |
|
|
114
|
+
| collapsedWidth | 收起宽度 | undefined | number | 否 | 48 |
|
|
115
|
+
| reverseArrow | 是否反转折叠箭头方向,右侧侧边栏可使用 | undefined | false | true | 否 | false(Vue Boolean 转换) |
|
|
116
|
+
| breakpoint | 响应式断点 | undefined | "xs" | "sm" | "md" | "lg" | "xl" | "xxl" | 否 | 未声明 |
|
|
117
|
+
| resizeDirections | 使用 ResizeBox 作为根组件后允许拖拽的方向 | undefined | ("top" | "bottom" | "right" | "left")[] | 否 | undefined |
|
|
118
|
+
| hideTrigger | 是否隐藏折叠触发器 | undefined | false | true | 否 | false(Vue Boolean 转换) |
|
|
119
|
+
| height | 见场景用法与类型 | undefined | number | 否 | 透传内层组件;默认值见对应组件 |
|
|
120
|
+
| minWidth | 见场景用法与类型 | undefined | number | 否 | 透传内层组件;默认值见对应组件 |
|
|
121
|
+
| minHeight | 见场景用法与类型 | undefined | number | 否 | 透传内层组件;默认值见对应组件 |
|
|
122
|
+
| maxHeight | 见场景用法与类型 | undefined | number | 否 | 透传内层组件;默认值见对应组件 |
|
|
123
|
+
| maxWidth | 见场景用法与类型 | undefined | number | 否 | 透传内层组件;默认值见对应组件 |
|
|
124
|
+
|
|
125
|
+
### Events
|
|
126
|
+
|
|
127
|
+
| 事件 | 用途 | 监听器签名(即事件参数) |
|
|
128
|
+
| --- | --- | --- |
|
|
129
|
+
| collapse | 展开/收起时触发 | undefined | ((...args: any[]) => any) & ((...args: any[]) => any) |
|
|
130
|
+
| update:collapsed | 收起状态变化时触发 | undefined | ((...args: any[]) => any) & ((...args: any[]) => any) |
|
|
131
|
+
| breakpoint | 响应式断点触发时触发 | undefined | ((...args: any[]) => any) & ((...args: any[]) => any) |
|
|
132
|
+
| moving | 见场景用法与类型 | undefined | (size: { width: number; height: number; }, ev: MouseEvent | KeyboardEvent) => any |
|
|
133
|
+
| update:width | 见场景用法与类型 | undefined | (width: number) => any |
|
|
134
|
+
| update:height | 见场景用法与类型 | undefined | (height: number) => any |
|
|
135
|
+
| movingStart | 见场景用法与类型 | undefined | (ev: MouseEvent) => any |
|
|
136
|
+
| movingEnd | 见场景用法与类型 | undefined | (ev: MouseEvent) => any |
|
|
137
|
+
|
|
138
|
+
### Slots
|
|
139
|
+
|
|
140
|
+
公开类型未逐项声明插槽;本页场景说明列出实际使用的插槽,不将任意插槽视为已支持。
|
|
141
|
+
|
|
142
|
+
### 实例方法
|
|
143
|
+
|
|
144
|
+
没有检索到显式 expose 或 Options API methods 的公开方法;不把 setup 内部函数当成稳定实例 API。
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
返回 [Layout 用法](./layout.md)。
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
<!-- Generated by pnpm generate:ai-usage. Edit script/ai-usage/content.md and script/ai-usage/. -->
|
|
2
|
+
# Layout AI 使用
|
|
3
|
+
|
|
4
|
+
适用版本:x-next@1.15.0;来源指纹:`47ea153587c8d0b3bf318977b10bde9f8dd4acff90c5818541ba6513252ad362`。
|
|
5
|
+
|
|
6
|
+
先读 [通用接入](../core.md)。公开导出:`Layout, LayoutContent, LayoutFooter, LayoutHeader, LayoutSidebar`;主要模型:无。完整 Props、Events、Slots、实例方法与服务签名见 [本地 API](./layout-api.md),包含本组件族全部子组件和别名。
|
|
7
|
+
|
|
8
|
+
按需样式:`x-next/style/layout`(包含 base.css、layout.css、resize-box.css)。代码块未单独引样式时在应用入口加载全量样式,或按实际所有组件加载 JS 入口;不要仅因复制一个组件页就漏掉其中的 Button 等组合依赖。
|
|
9
|
+
|
|
10
|
+
## 场景用法
|
|
11
|
+
|
|
12
|
+
以下示例从本地 `src/docs/components/layout.md` 显式导入到独立 AI 源,补齐局部注册、状态和样式后进行严格模板检查。上方已核验行为优先;原始 prop 默认值、包装透传和示例业务适配分别查 [完整 API](./layout-api.md) 与场景说明。类型通过不代表所有散文和交互已验证。
|
|
13
|
+
|
|
14
|
+
### 用途与选型
|
|
15
|
+
|
|
16
|
+
提供页头、侧边栏、内容区和页脚组合,适合搭建后台系统页面框架。
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### 何时使用
|
|
20
|
+
|
|
21
|
+
- 页面需要稳定组织 Header、Sidebar、Content、Footer 等区域。
|
|
22
|
+
- 后台系统需要侧边导航和主内容区联动。
|
|
23
|
+
- 侧边栏需要支持折叠、响应式收起或拖拽调整宽度。
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### 基础用法
|
|
27
|
+
|
|
28
|
+
```vue
|
|
29
|
+
<script setup lang="ts">
|
|
30
|
+
import 'x-next/style.css';
|
|
31
|
+
import { Layout, LayoutHeader, LayoutSidebar, LayoutContent, LayoutFooter } from 'x-next';
|
|
32
|
+
|
|
33
|
+
</script>
|
|
34
|
+
<template>
|
|
35
|
+
<Layout class="demo-layout">
|
|
36
|
+
<LayoutHeader>Header</LayoutHeader>
|
|
37
|
+
<Layout has-sidebar>
|
|
38
|
+
<LayoutSidebar :width="120">Sidebar</LayoutSidebar>
|
|
39
|
+
<LayoutContent>Content</LayoutContent>
|
|
40
|
+
</Layout>
|
|
41
|
+
<LayoutFooter>Footer</LayoutFooter>
|
|
42
|
+
</Layout>
|
|
43
|
+
</template>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 常见结构
|
|
47
|
+
|
|
48
|
+
```vue
|
|
49
|
+
<script setup lang="ts">
|
|
50
|
+
import 'x-next/style.css';
|
|
51
|
+
import { Layout, LayoutHeader, LayoutContent, LayoutFooter, LayoutSidebar } from 'x-next';
|
|
52
|
+
|
|
53
|
+
</script>
|
|
54
|
+
<template>
|
|
55
|
+
<Layout class="layout-doc-demo">
|
|
56
|
+
<LayoutHeader>Header</LayoutHeader>
|
|
57
|
+
<LayoutContent>Content</LayoutContent>
|
|
58
|
+
<LayoutFooter>Footer</LayoutFooter>
|
|
59
|
+
</Layout>
|
|
60
|
+
|
|
61
|
+
<Layout class="layout-doc-demo">
|
|
62
|
+
<LayoutHeader>Header</LayoutHeader>
|
|
63
|
+
<Layout has-sidebar>
|
|
64
|
+
<LayoutSidebar :width="128">Left</LayoutSidebar>
|
|
65
|
+
<LayoutContent>Content</LayoutContent>
|
|
66
|
+
<LayoutSidebar :width="128" reverse-arrow>Right</LayoutSidebar>
|
|
67
|
+
</Layout>
|
|
68
|
+
<LayoutFooter>Footer</LayoutFooter>
|
|
69
|
+
</Layout>
|
|
70
|
+
</template>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 可折叠侧边栏
|
|
74
|
+
|
|
75
|
+
```vue
|
|
76
|
+
<script setup lang="ts">
|
|
77
|
+
import 'x-next/style.css';
|
|
78
|
+
import { Layout, LayoutSidebar, LayoutContent, Space, Button } from 'x-next';
|
|
79
|
+
import { ref } from 'vue';
|
|
80
|
+
|
|
81
|
+
const collapsed = ref(false);
|
|
82
|
+
</script>
|
|
83
|
+
<template>
|
|
84
|
+
<Layout class="layout-doc-demo" has-sidebar>
|
|
85
|
+
<LayoutSidebar
|
|
86
|
+
v-model:collapsed="collapsed"
|
|
87
|
+
collapsible
|
|
88
|
+
theme="dark"
|
|
89
|
+
:width="180"
|
|
90
|
+
:collapsed-width="56"
|
|
91
|
+
>
|
|
92
|
+
{{ collapsed ? '已收起' : '已展开' }}
|
|
93
|
+
</LayoutSidebar>
|
|
94
|
+
<LayoutContent>Content</LayoutContent>
|
|
95
|
+
</Layout>
|
|
96
|
+
<Space>
|
|
97
|
+
<Button @click="collapsed = false">展开</Button>
|
|
98
|
+
<Button @click="collapsed = true">收起</Button>
|
|
99
|
+
</Space>
|
|
100
|
+
</template>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### 自定义触发器
|
|
104
|
+
|
|
105
|
+
```vue
|
|
106
|
+
<script setup lang="ts">
|
|
107
|
+
import 'x-next/style.css';
|
|
108
|
+
import { Layout, LayoutSidebar, LayoutContent } from 'x-next';
|
|
109
|
+
import { ref } from 'vue';
|
|
110
|
+
|
|
111
|
+
const collapsed = ref(false);
|
|
112
|
+
</script>
|
|
113
|
+
<template>
|
|
114
|
+
<Layout class="layout-doc-demo" has-sidebar>
|
|
115
|
+
<LayoutSidebar
|
|
116
|
+
v-model:collapsed="collapsed"
|
|
117
|
+
collapsible
|
|
118
|
+
:width="180"
|
|
119
|
+
:collapsed-width="64"
|
|
120
|
+
>
|
|
121
|
+
{{ collapsed ? 'Mini' : 'Custom Trigger' }}
|
|
122
|
+
<template #trigger="{ collapsed: slotCollapsed }">
|
|
123
|
+
{{ slotCollapsed ? '展开' : '收起' }}
|
|
124
|
+
</template>
|
|
125
|
+
</LayoutSidebar>
|
|
126
|
+
<LayoutContent>Content</LayoutContent>
|
|
127
|
+
</Layout>
|
|
128
|
+
</template>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### 响应式与事件
|
|
132
|
+
|
|
133
|
+
```vue
|
|
134
|
+
<script setup lang="ts">
|
|
135
|
+
import 'x-next/style.css';
|
|
136
|
+
import { Layout, LayoutSidebar, LayoutContent } from 'x-next';
|
|
137
|
+
import { ref } from 'vue';
|
|
138
|
+
|
|
139
|
+
const collapsed = ref(false);
|
|
140
|
+
|
|
141
|
+
const handleCollapse = (nextCollapsed: boolean, type: 'clickTrigger' | 'responsive') => {
|
|
142
|
+
console.log(nextCollapsed, type);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const handleBreakpoint = (nextCollapsed: boolean) => {
|
|
146
|
+
console.log(nextCollapsed);
|
|
147
|
+
};
|
|
148
|
+
</script>
|
|
149
|
+
<template>
|
|
150
|
+
<Layout class="layout-doc-demo" has-sidebar>
|
|
151
|
+
<LayoutSidebar
|
|
152
|
+
v-model:collapsed="collapsed"
|
|
153
|
+
collapsible
|
|
154
|
+
breakpoint="lg"
|
|
155
|
+
:width="190"
|
|
156
|
+
:collapsed-width="72"
|
|
157
|
+
@collapse="handleCollapse"
|
|
158
|
+
@breakpoint="handleBreakpoint"
|
|
159
|
+
>
|
|
160
|
+
{{ collapsed ? 'lg' : 'breakpoint="lg"' }}
|
|
161
|
+
</LayoutSidebar>
|
|
162
|
+
<LayoutContent>Content</LayoutContent>
|
|
163
|
+
</Layout>
|
|
164
|
+
</template>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### 可拖拽侧边栏
|
|
168
|
+
|
|
169
|
+
```vue
|
|
170
|
+
<script setup lang="ts">
|
|
171
|
+
import 'x-next/style.css';
|
|
172
|
+
import { Layout, LayoutSidebar, LayoutContent } from 'x-next';
|
|
173
|
+
import { ref } from 'vue';
|
|
174
|
+
|
|
175
|
+
const sidebarWidth = ref(240);
|
|
176
|
+
</script>
|
|
177
|
+
<template>
|
|
178
|
+
<Layout class="layout-doc-demo" has-sidebar>
|
|
179
|
+
<LayoutSidebar
|
|
180
|
+
:width="sidebarWidth"
|
|
181
|
+
:min-width="160"
|
|
182
|
+
:max-width="520"
|
|
183
|
+
:resize-directions="['right']"
|
|
184
|
+
@moving="(size) => {
|
|
185
|
+
sidebarWidth = size.width;
|
|
186
|
+
}"
|
|
187
|
+
>
|
|
188
|
+
拖动右侧边缘
|
|
189
|
+
</LayoutSidebar>
|
|
190
|
+
<LayoutContent>当前宽度:{{ sidebarWidth }}px</LayoutContent>
|
|
191
|
+
</Layout>
|
|
192
|
+
</template>
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### 与 Menu 组合
|
|
196
|
+
|
|
197
|
+
```vue
|
|
198
|
+
<script setup lang="ts">
|
|
199
|
+
import 'x-next/style.css';
|
|
200
|
+
import { Layout, LayoutSidebar, Menu, MenuItem, MenuSubMenu, LayoutContent } from 'x-next';
|
|
201
|
+
const collapsed = ref(false);
|
|
202
|
+
|
|
203
|
+
import { ref } from 'vue';
|
|
204
|
+
|
|
205
|
+
const selectedKeys = ref(['overview']);
|
|
206
|
+
</script>
|
|
207
|
+
<template>
|
|
208
|
+
<Layout class="layout-doc-demo" has-sidebar>
|
|
209
|
+
<LayoutSidebar collapsible theme="dark" :width="210" :collapsed-width="64">
|
|
210
|
+
<Menu v-model:selected-keys="selectedKeys" theme="dark">
|
|
211
|
+
<MenuItem key="overview">概览</MenuItem>
|
|
212
|
+
<MenuSubMenu key="workspace" title="工作台">
|
|
213
|
+
<MenuItem key="components">组件</MenuItem>
|
|
214
|
+
<MenuItem key="docs">文档</MenuItem>
|
|
215
|
+
</MenuSubMenu>
|
|
216
|
+
</Menu>
|
|
217
|
+
</LayoutSidebar>
|
|
218
|
+
<LayoutContent>Content</LayoutContent>
|
|
219
|
+
</Layout>
|
|
220
|
+
</template>
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### 已知限制
|
|
224
|
+
|
|
225
|
+
- `collapsedWidth` 可以设为 `0`,但当前不会生成侧边栏外部的零宽特殊触发器;需要重新展开时请提供外部按钮或自定义布局。
|
|
226
|
+
- `resizeDirections` 会让 Sidebar 复用 ResizeBox 作为根组件,拖拽事件请参考 ResizeBox 文档。
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
返回 [AI 索引](../index.md)。先查本页与 [本地 API](./layout-api.md);需要更深类型时查 [公开组件导航](../catalog.md),不默认上网查找本包用法。
|