index.vue
1017 Bytes
<!--
* @Date: 2022-08-29 14:31:20
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-09-16 17:13:01
* @FilePath: /data-table/src/components/EmailField/index.vue
* @Description: 单行文本输入框
-->
<template>
<div class="text-field-page">
<div class="label">{{ item.component_props.label }}<span v-if="item.component_props.required"> *</span></div>
<van-field v-model="item.value" :name="item.name" type="email" :placeholder="item.component_props.placeholder" :rules="rules"
:required="item.component_props.required" clearable />
</div>
</template>
<script setup>
const props = defineProps({
item: Object
});
const pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
const rules = [{ pattern, message: '请输入正确内容邮箱' }]
</script>
<style lang="less" scoped>
.text-field-page {
.label {
padding: 1rem 1rem 0 1rem;
font-size: 0.9rem;
font-weight: bold;
span {
color: red;
}
}
}
</style>