<template>
<div class="group">
<div v-for="( item, index ) in macAddress" :key="index" class="wrapper">
<text v-if="index > 0">:</text>
<input v-model="macAddress[index]" @input="onInput" maxlength="2" placeholder="" />
</div>
</div>
</template>
<script>
export default {
name: 'macInput',
behaviors: ['uni://form-field'],
data() {
return {
macAddress: ['', '', '', '', '', '']
}
},
methods: {
onInput(event) {
let fullMac = this.macAddress.join(':')
console.log("fullMac=", fullMac)
this.$emit('update:modelValue', fullMac)
}
}
}
</script>
这是我参考文档示例写的一个mac地址输入组件(微信小程序上使用),引入了behaviors: ['uni://form-field']去做表单验证;但在父组件校验的时候,返回的值是null,是我的写法有误吗?
0 个回复