Skip to content

Commit 5592bc4

Browse files
author
xuqingkai
committed
feat: ✨ Segmented分段器change事件参数类型扩充为SegmentedOption
Closes: #204
1 parent d871371 commit 5592bc4

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

docs/component/segmented.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const list1 = ref([
119119

120120
| 事件名称 | 说明 | 参数 | 最低版本 |
121121
| -------- | -------------------------- | ----------- | -------- |
122-
| change | 选项切换时触发 | `{ value }` | 0.1.23 |
122+
| change | 选项切换时触发 | `SegmentedOption` | 0.1.23 |
123123

124124
## Slots
125125

src/pages/segmented/Index.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<page-wraper>
55
<demo-block title="大型分段器" transparent>
66
<view class="section">
7-
<wd-segmented :options="list" v-model:value="current" size="large"></wd-segmented>
7+
<wd-segmented :options="list" v-model:value="current" size="large" @change="handleChange"></wd-segmented>
88
</view>
99
</demo-block>
1010
<demo-block title="默认分段器" transparent>
@@ -33,7 +33,7 @@
3333

3434
<demo-block title="自定义渲染分段器标签" transparent>
3535
<view class="section">
36-
<wd-segmented :options="list1" v-model:value="current4" :vibrate-short="true">
36+
<wd-segmented :options="list1" v-model:value="current4" :vibrate-short="true" @change="handleChange">
3737
<template #label="{ option }">
3838
<view class="section-slot">
3939
<image style="border-radius: 50%; width: 32px; height: 32px" :src="option.payload.avatar" />
@@ -50,6 +50,7 @@
5050
</view>
5151
</template>
5252
<script lang="ts" setup>
53+
import type { SegmentedOption } from '@/uni_modules/wot-design-uni/components/wd-segmented/types'
5354
import { ref } from 'vue'
5455
5556
const list = ref<string[]>(['评论', '点赞', '贡献', '打赏'])
@@ -96,6 +97,10 @@ const current3 = ref('打赏')
9697
const current4 = ref('韩梅梅')
9798
9899
const current5 = ref('评论')
100+
101+
function handleChange(option: SegmentedOption) {
102+
console.log(option)
103+
}
99104
</script>
100105
<style lang="scss" scoped>
101106
.section {

src/uni_modules/wot-design-uni/components/wd-message-box/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* @Author: weisheng
33
* @Date: 2022-12-14 17:33:21
4-
* @LastEditTime: 2024-01-26 11:19:42
4+
* @LastEditTime: 2024-04-01 12:30:51
55
* @LastEditors: weisheng
66
* @Description:
77
* @FilePath: \wot-design-uni\src\uni_modules\wot-design-uni\components\wd-message-box\index.ts
@@ -41,7 +41,7 @@ export function useMessage(selector: string = ''): Message {
4141
provide(messageOptionKey, messageOption)
4242

4343
const createMethod = (type: MessageType) => {
44-
// 优先级:options->toastOptions->defaultOptions
44+
// 优先级:options->MessageOptions->defaultOptions
4545
return (options: MessageOptions | string) => {
4646
const messageOptions = deepMerge({ type: type }, typeof options === 'string' ? { title: options } : options) as MessageOptions
4747
if (messageOptions.type === 'confirm' || messageOptions.type === 'prompt') {

src/uni_modules/wot-design-uni/components/wd-segmented/wd-segmented.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ function updateCurrentIndex() {
117117
} else {
118118
const value = isObj(props.options[0]) ? props.options[0].value : props.options[0]
119119
emit('update:value', value)
120-
emit('change', { value })
120+
emit('change', isObj(props.options[0]) ? props.options[0] : { value })
121121
}
122122
}
123123
@@ -130,7 +130,7 @@ function handleClick(option: string | number | SegmentedOption, index: number) {
130130
activeIndex.value = index
131131
updateActiveStyle()
132132
emit('update:value', value)
133-
emit('change', { value })
133+
emit('change', isObj(option) ? option : { value })
134134
}
135135
</script>
136136

0 commit comments

Comments
 (0)