switch和star组件兼容vue3的双向绑定

master
yutent 2023-05-26 00:06:18 +08:00
parent cb97ebb73e
commit 28877df64a
3 changed files with 8 additions and 5 deletions

View File

@ -171,6 +171,7 @@ class Star extends Component {
} else {
this.value = tmp.i + tmp.f
}
this.$emit('input', { value: this.value })
this.$emit('change', { value: this.value })
}
}

View File

@ -11,8 +11,7 @@ class Switch extends Component {
size: 'l',
value: {
type: Boolean,
default: false,
attribute: false
default: false
},
inactiveText: '',
activeText: '',
@ -195,11 +194,13 @@ class Switch extends Component {
value: this.value
}
this.$emit('input')
this.$emit('change', data)
}
handleClick(ev) {
if (ev.type === 'click' || ev.keyCode === 32) {
ev.preventDefault()
this.toggleCheck(ev)
}
}

View File

@ -243,7 +243,8 @@ class Pager extends Component {
this.page = num
this.$emit('page-changed', { data: num })
console.log(this)
this.$emit('page-change', { data: num })
}
}
@ -252,9 +253,9 @@ class Pager extends Component {
let n = +ev.target.value
if (n === n) {
this.page = n
this.$emit('page-changed', { data: this.page })
this.$emit('page-change', { data: n })
}
ev.target.value = this.page
ev.target.value = n
}
}