Commit 8af49c5a authored by Facius's avatar Facius

fix: 完工页面纯数字输入防止粘贴非数字

parent c4508d5a
...@@ -2,28 +2,28 @@ ...@@ -2,28 +2,28 @@
export default { export default {
data() { data() {
return { return {
dataValue: '' dataValue: '',
} }
}, },
watch: { watch: {
value: function(val) { value: function(val) {
this.dataValue = val this.dataValue = val
} },
}, },
props: { props: {
value: { value: {
type: [String, Number], type: [String, Number],
default: '' default: '',
}, },
/** 索引值 用于更新数据 */ /** 索引值 用于更新数据 */
itemIndex:Number, itemIndex: Number,
groupIndex:Number, groupIndex: Number,
/** 包含数据源 */ /** 包含数据源 */
item: Object, item: Object,
disabled: { disabled: {
type: Boolean, type: Boolean,
default: false default: false,
} },
}, },
mounted() { mounted() {
...@@ -34,13 +34,19 @@ export default { ...@@ -34,13 +34,19 @@ export default {
methods: { methods: {
// 输入的值 // 输入的值
valueChange(val) { valueChange(val) {
if (this.type == 'digit') {
// 防止粘贴非数字
val = val.replace(/[^\d.]/gi, '')
this.$nextTick(() => {
this.dataValue = val
})
}
const data = { const data = {
groupIndex: this.groupIndex,// 左侧菜单下标 groupIndex: this.groupIndex, // 左侧菜单下标
itemIndex:this.itemIndex,//右侧某一项下标 itemIndex: this.itemIndex, //右侧某一项下标
value: val value: val,
} }
this.$emit('value-change', data) this.$emit('value-change', data)
} },
} },
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment