Commit 8af49c5a authored by Facius's avatar Facius

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

parent c4508d5a
/** 自定义组件 共同逻辑 */
export default {
data() {
return {
dataValue: ''
}
data() {
return {
dataValue: '',
}
},
watch: {
value: function(val) {
this.dataValue = val
},
watch: {
value: function(val) {
this.dataValue = val
}
},
props: {
value: {
type: [String, Number],
default: '',
},
props: {
value: {
type: [String, Number],
default: ''
},
/** 索引值 用于更新数据 */
itemIndex:Number,
groupIndex:Number,
/** 包含数据源 */
item: Object,
disabled: {
type: Boolean,
default: false
}
/** 索引值 用于更新数据 */
itemIndex: Number,
groupIndex: Number,
/** 包含数据源 */
item: Object,
disabled: {
type: Boolean,
default: false,
},
},
mounted() {
mounted() {
/** 如果有值以传入值为主 如果无值 已默认值为主 */
this.dataValue = this.value
},
this.dataValue = this.value
},
methods: {
methods: {
// 输入的值
valueChange(val) {
const data = {
groupIndex: this.groupIndex,// 左侧菜单下标
itemIndex:this.itemIndex,//右侧某一项下标
value: val
}
this.$emit('value-change', data)
}
}
valueChange(val) {
if (this.type == 'digit') {
// 防止粘贴非数字
val = val.replace(/[^\d.]/gi, '')
this.$nextTick(() => {
this.dataValue = val
})
}
const data = {
groupIndex: this.groupIndex, // 左侧菜单下标
itemIndex: this.itemIndex, //右侧某一项下标
value: val,
}
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