This commit is contained in:
2025-04-14 11:42:21 +08:00
parent b614f2482e
commit a706b60c90
30 changed files with 700 additions and 9 deletions

41
src/components/XForm.vue Normal file
View File

@@ -0,0 +1,41 @@
<script setup>
import {showToast} from "../utils/uils.js";
const {model, rules} = defineProps({
model: {
type: Object,
default: {},
},
rules: {
type: Object,
default: {},
}
});
const verify = () => {
Object.entries(model).forEach(([key, value]) => {
if (!rules[key].reg.test(value)) {
showToast({
icon: 'error',
mask: true,
title: rules[key].msg,
});
throw new Error(rules[key].msg);
}
});
}
defineExpose({
verify
});
</script>
<template>
<view>
<slot></slot>
</view>
</template>
<style scoped lang="scss">
</style>