3***@qq.com
3***@qq.com
  • 发布:2025-01-21 17:49
  • 更新:2025-01-21 17:49
  • 阅读:39

behaviors: ['uni://form-field']的具体用法是怎么样?

分类:uni-app
<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,是我的写法有误吗?

2025-01-21 17:49 负责人:无 分享
已邀请:

要回复问题请先登录注册