mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-03-01 13:36:55 +08:00
fix(input): forget to remove :on=$listeners of input, this may cause some native event be put into wrong handler
This commit is contained in:
parent
93ee695c08
commit
73a77492b6
@ -100,6 +100,7 @@ export default {
|
|||||||
@focus="handleFocus"
|
@focus="handleFocus"
|
||||||
@change="handleChange"
|
@change="handleChange"
|
||||||
@keyup="handleKeyUp"
|
@keyup="handleKeyUp"
|
||||||
|
@input="handleInput"
|
||||||
/>
|
/>
|
||||||
<br>
|
<br>
|
||||||
value: {{ value }}
|
value: {{ value }}
|
||||||
@ -121,6 +122,23 @@ export default {
|
|||||||
return {
|
return {
|
||||||
value: null
|
value: null
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleFocus () {
|
||||||
|
this.$NMessage.success('focus')
|
||||||
|
},
|
||||||
|
handleBlur () {
|
||||||
|
this.$NMessage.success('blur')
|
||||||
|
},
|
||||||
|
handleInput (value) {
|
||||||
|
this.$NMessage.success('input: ' + value)
|
||||||
|
},
|
||||||
|
handleChange (value) {
|
||||||
|
this.$NMessage.success('change: ' + value)
|
||||||
|
},
|
||||||
|
handleKeyUp (e) {
|
||||||
|
this.$NMessage.success('keyup')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script></textarea>
|
</script></textarea>
|
||||||
@ -353,6 +371,9 @@ export default {
|
|||||||
handleBlur () {
|
handleBlur () {
|
||||||
this.$NMessage.success('blur')
|
this.$NMessage.success('blur')
|
||||||
},
|
},
|
||||||
|
handleInput (value) {
|
||||||
|
this.$NMessage.success('input: ' + value)
|
||||||
|
},
|
||||||
handleChange (value) {
|
handleChange (value) {
|
||||||
this.$NMessage.success('change: ' + value)
|
this.$NMessage.success('change: ' + value)
|
||||||
},
|
},
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<div class="demo">
|
<div class="demo">
|
||||||
<n-nimbus-service-layout
|
<n-nimbus-service-layout
|
||||||
icon="md-contacts"
|
icon="md-contacts"
|
||||||
name="NAIVE UI (0.1.93)"
|
name="NAIVE UI (0.1.94)"
|
||||||
:padding-body="false"
|
:padding-body="false"
|
||||||
:items="items"
|
:items="items"
|
||||||
>
|
>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "naive-ui",
|
"name": "naive-ui",
|
||||||
"version": "0.1.93",
|
"version": "0.1.94",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<textarea
|
<textarea
|
||||||
|
ref="textarea"
|
||||||
class="n-input__textarea"
|
class="n-input__textarea"
|
||||||
:class="{
|
:class="{
|
||||||
[`n-input__textarea--${size}-size`]: true
|
[`n-input__textarea--${size}-size`]: true
|
||||||
@ -15,11 +16,13 @@
|
|||||||
:placeholder="placeholder"
|
:placeholder="placeholder"
|
||||||
:value="value"
|
:value="value"
|
||||||
:disabled="disabled === true"
|
:disabled="disabled === true"
|
||||||
v-on="$listeners"
|
|
||||||
@blur="handleBlur"
|
@blur="handleBlur"
|
||||||
@focus="handleFocus"
|
@focus="handleFocus"
|
||||||
@input="handleInput"
|
@input="handleInput"
|
||||||
|
@change="handleChange"
|
||||||
@keyup="handleKeyUp"
|
@keyup="handleKeyUp"
|
||||||
|
@compositionstart="handleCompositionStart"
|
||||||
|
@compositionend="handleCompositionEnd"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
@ -30,6 +33,7 @@
|
|||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
|
ref="input"
|
||||||
:type="type"
|
:type="type"
|
||||||
class="n-input__input"
|
class="n-input__input"
|
||||||
:class="{
|
:class="{
|
||||||
@ -38,13 +42,15 @@
|
|||||||
[`n-input__input--icon`]: icon
|
[`n-input__input--icon`]: icon
|
||||||
}"
|
}"
|
||||||
:placeholder="placeholder"
|
:placeholder="placeholder"
|
||||||
:value="value"
|
|
||||||
:disabled="disabled === true"
|
:disabled="disabled === true"
|
||||||
:maxlength="maxlength"
|
:maxlength="maxlength"
|
||||||
@blur="handleBlur"
|
@blur="handleBlur"
|
||||||
@focus="handleFocus"
|
@focus="handleFocus"
|
||||||
@input="handleInput"
|
@input="handleInput"
|
||||||
|
@change="handleChange"
|
||||||
@keyup="handleKeyUp"
|
@keyup="handleKeyUp"
|
||||||
|
@compositionstart="handleCompositionStart"
|
||||||
|
@compositionend="handleCompositionEnd"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
v-if="icon"
|
v-if="icon"
|
||||||
@ -65,7 +71,7 @@ export default {
|
|||||||
},
|
},
|
||||||
model: {
|
model: {
|
||||||
prop: 'value',
|
prop: 'value',
|
||||||
event: 'change'
|
event: 'input'
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
type: {
|
type: {
|
||||||
@ -105,9 +111,22 @@ export default {
|
|||||||
default: 'false'
|
default: 'false'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
isComposing: false
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
handleCompositionStart () {
|
||||||
|
this.isComposing = true
|
||||||
|
},
|
||||||
|
handleCompositionEnd (event) {
|
||||||
|
this.isComposing = false
|
||||||
|
this.handleInput(event)
|
||||||
|
},
|
||||||
handleInput (e) {
|
handleInput (e) {
|
||||||
this.$emit('change', e.target.value)
|
if (this.isComposing) return
|
||||||
|
this.$emit('input', e.target.value)
|
||||||
},
|
},
|
||||||
handleBlur (e) {
|
handleBlur (e) {
|
||||||
this.$emit('blur', e)
|
this.$emit('blur', e)
|
||||||
@ -116,7 +135,11 @@ export default {
|
|||||||
this.$emit('focus', e)
|
this.$emit('focus', e)
|
||||||
},
|
},
|
||||||
handleKeyUp (e) {
|
handleKeyUp (e) {
|
||||||
|
if (this.isComposing) return
|
||||||
this.$emit('keyup', e)
|
this.$emit('keyup', e)
|
||||||
|
},
|
||||||
|
handleChange (e) {
|
||||||
|
this.$emit('change', e.target.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user