Skip to content

Commit 82357f9

Browse files
fix: 🐛 修复Input组件@input事件参数错误的问题
1 parent 2da6c50 commit 82357f9

File tree

3 files changed

+34
-27
lines changed

3 files changed

+34
-27
lines changed

src/pages/input/Index.vue

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,56 @@
11
<template>
22
<page-wraper>
33
<demo-block title="基本用法">
4-
<wd-input type="text" v-model="value" placeholder="请输入用户名" @change="handleChange" @blur="handleBlur" />
4+
<wd-input type="text" @input="handleInput" v-model="value" placeholder="请输入用户名" @change="handleChange" @blur="handleBlur" />
55
</demo-block>
66
<demo-block title="禁用状态">
7-
<wd-input type="text" v-model="value1" disabled />
7+
<wd-input type="text" @input="handleInput" v-model="value1" disabled />
88
</demo-block>
99
<demo-block title="只读状态">
10-
<wd-input type="text" v-model="value2" readonly />
10+
<wd-input type="text" @input="handleInput" v-model="value2" readonly />
1111
</demo-block>
1212
<demo-block title="错误状态">
13-
<wd-input type="text" v-model="value3" placeholder="请输入用户名" error />
13+
<wd-input type="text" @input="handleInput" v-model="value3" placeholder="请输入用户名" error />
1414
</demo-block>
1515
<demo-block title="清空按钮">
16-
<wd-input type="text" v-model="value4" clearable @change="handleChange1" />
16+
<wd-input type="text" @input="handleInput" v-model="value4" clearable @change="handleChange1" />
1717
</demo-block>
1818
<demo-block title="密码框">
19-
<wd-input type="text" v-model="value5" clearable show-password @change="handleChange2" />
19+
<wd-input type="text" @input="handleInput" v-model="value5" clearable show-password @change="handleChange2" />
2020
</demo-block>
2121
<demo-block title="数字类型">
22-
<wd-input type="number" v-model="value9" />
22+
<wd-input type="number" @input="handleInput" v-model="value9" />
2323
</demo-block>
2424
<demo-block title="设置前后Icon">
25-
<wd-input type="text" v-model="value6" prefix-icon="dong" suffix-icon="list" clearable @change="handleChange3" />
25+
<wd-input type="text" v-model="value6" @input="handleInput" prefix-icon="dong" suffix-icon="list" clearable @change="handleChange3" />
2626
</demo-block>
2727
<demo-block title="字数限制">
28-
<wd-input type="text" v-model="value7" :maxlength="20" show-word-limit />
28+
<wd-input type="text" v-model="value7" @input="handleInput" :maxlength="20" show-word-limit />
2929
</demo-block>
3030
<demo-block title="取消底部边框,自定义使用">
31-
<wd-input v-model="value8" no-border placeholder="请输入价格" custom-style="display: inline-block; width: 70px; vertical-align: middle;" />
31+
<wd-input
32+
v-model="value8"
33+
@input="handleInput"
34+
no-border
35+
placeholder="请输入价格"
36+
custom-style="display: inline-block; width: 70px; vertical-align: middle;"
37+
/>
3238
<text class="custom-txt">元</text>
3339
</demo-block>
3440
<demo-block title="cell 类型" transparent>
3541
<wd-cell-group border>
36-
<wd-input type="text" label="基本用法" v-model="value12" placeholder="请输入..." />
37-
<wd-input type="text" label="禁用" v-model="value13" disabled placeholder="用户名" />
38-
<wd-input type="text" label="清除、密码" v-model="value14" placeholder="密码" clearable show-password />
39-
<wd-input type="text" label="错误状态" v-model="value15" placeholder="请输入用户名" error />
40-
<wd-input type="text" label="必填" v-model="value16" placeholder="请输入用户名" required />
41-
<wd-input type="text" label="图标" v-model="value17" placeholder="请输入..." prefix-icon="dong" suffix-icon="list" />
42-
<wd-input type="text" label="自定义插槽" center v-model="value18" placeholder="请输入..." use-suffix-slot clearable>
42+
<wd-input type="text" label="基本用法" v-model="value12" @input="handleInput" placeholder="请输入..." />
43+
<wd-input type="text" label="禁用" v-model="value13" @input="handleInput" disabled placeholder="用户名" />
44+
<wd-input type="text" label="清除、密码" v-model="value14" @input="handleInput" placeholder="密码" clearable show-password />
45+
<wd-input type="text" label="错误状态" v-model="value15" @input="handleInput" placeholder="请输入用户名" error />
46+
<wd-input type="text" label="必填" v-model="value16" @input="handleInput" placeholder="请输入用户名" required />
47+
<wd-input type="text" label="图标" v-model="value17" @input="handleInput" placeholder="请输入..." prefix-icon="dong" suffix-icon="list" />
48+
<wd-input type="text" label="自定义插槽" center v-model="value18" @input="handleInput" placeholder="请输入..." use-suffix-slot clearable>
4349
<template #suffix>
4450
<wd-button size="small" custom-class="button">获取验证码</wd-button>
4551
</template>
4652
</wd-input>
47-
<wd-input type="text" label="大尺寸" clearable size="large" v-model="value19" placeholder="请输入..." />
53+
<wd-input type="text" label="大尺寸" clearable size="large" v-model="value19" @input="handleInput" placeholder="请输入..." />
4854
</wd-cell-group>
4955
</demo-block>
5056
</page-wraper>
@@ -86,6 +92,10 @@ function handleChange3(event: any) {
8692
function handleBlur(event: any) {
8793
console.log('失焦', event)
8894
}
95+
96+
function handleInput(event: any) {
97+
console.log(event)
98+
}
8999
</script>
90100
<style lang="scss" scoped>
91101
.wot-theme-dark {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,12 @@ function handleFocus({ detail }: any) {
239239
isFocus.value = true
240240
emit('focus', detail)
241241
}
242-
function handleInput() {
242+
function handleInput({ detail }: any) {
243243
emit('update:modelValue', inputValue.value)
244-
emit('input', inputValue.value)
244+
emit('input', detail)
245245
}
246-
function handleKeyboardheightchange(event: any) {
247-
emit('keyboardheightchange', event.detail)
246+
function handleKeyboardheightchange({ detail }: any) {
247+
emit('keyboardheightchange', detail)
248248
}
249249
function handleConfirm({ detail }: any) {
250250
emit('confirm', detail)

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,10 @@ function handleFocus({ detail }: any) {
244244
emit('focus', detail)
245245
}
246246
// input事件需要传入
247-
function handleInput() {
247+
function handleInput({ detail }: any) {
248248
inputValue.value = formatValue(inputValue.value as string)
249249
emit('update:modelValue', inputValue.value)
250-
emit('input', inputValue.value)
250+
emit('input', detail)
251251
}
252252
function handleKeyboardheightchange({ detail }: any) {
253253
emit('keyboardheightchange', detail)
@@ -261,9 +261,6 @@ function handleLineChange({ detail }: any) {
261261
function onClickPrefixIcon() {
262262
emit('clickprefixicon')
263263
}
264-
function handleClick(event: MouseEvent) {
265-
emit('click', event)
266-
}
267264
</script>
268265

269266
<style lang="scss" scoped>

0 commit comments

Comments
 (0)