mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-14 17:31:02 +08:00
4560adfdf8
* refactor(style): adjust component size to large/default/small * refactor(components): avatar size & use flex instead of block * refactor(components): adjust check button size * refactor(components): adjust tag size * refactor(components): adjust size doc * fix(components): datetime-picker demo style width * refactor(components): color-picker size & block to flex * refactor(components): adjust slider input size * refactor(components): adjust radio input size for demo * refactor(components): adjust select size & docs * refactor(components): adjust form radio size & docs * refactor(components): add windicss for docs * refactor(components): adjust skeleton avatar size to css var * refactor(components): simplify typography size demo * refactor(components): adjust dropdown size & demo * refactor(components): adjust descriptions size * fix(components): datetime-picker showcase class pollute global button * chore(ci): upgrade docs dependencies to fix ci * fix(ci): add highlight because vitepress not export it * fix(ci): disable line for no-console * fix(ci): remove mini to fix test * fix(style): code font size * fix(style): button span flex style * fix(style): button padding horizontal default 15px * refactor(components): adjust tag padding size & demo * refactor(components): adjust form line-height for input * refactor(components): adjust dropdown menu size & button padding * fix(style): picker separator block to flex center * fix: dropdown button span items-center * style: adjust input-with-icon & size demo & fix input vitepress load * chore: upgrade dependencies * chore: upgrade dependencies * ci: fix website build * ci: regenerate pnpm-lock.yaml * ci: use dev pnpm-lock * ci: update pnpm-lock.yaml
96 lines
2.2 KiB
Vue
96 lines
2.2 KiB
Vue
<template>
|
|
<el-form
|
|
ref="dynamicValidateForm"
|
|
:model="dynamicValidateForm"
|
|
label-width="120px"
|
|
class="demo-dynamic"
|
|
>
|
|
<el-form-item
|
|
prop="email"
|
|
label="Email"
|
|
:rules="[
|
|
{
|
|
required: true,
|
|
message: 'Please input email address',
|
|
trigger: 'blur',
|
|
},
|
|
{
|
|
type: 'email',
|
|
message: 'Please input correct email address',
|
|
trigger: ['blur', 'change'],
|
|
},
|
|
]"
|
|
>
|
|
<el-input v-model="dynamicValidateForm.email"></el-input>
|
|
</el-form-item>
|
|
<el-form-item
|
|
v-for="(domain, index) in dynamicValidateForm.domains"
|
|
:key="domain.key"
|
|
:label="'Domain' + index"
|
|
:prop="'domains.' + index + '.value'"
|
|
:rules="{
|
|
required: true,
|
|
message: 'domain can not be null',
|
|
trigger: 'blur',
|
|
}"
|
|
>
|
|
<el-input v-model="domain.value"></el-input>
|
|
<el-button class="mt-2" @click.prevent="removeDomain(domain)"
|
|
>Delete</el-button
|
|
>
|
|
</el-form-item>
|
|
<el-form-item>
|
|
<el-button type="primary" @click="submitForm('dynamicValidateForm')"
|
|
>Submit</el-button
|
|
>
|
|
<el-button @click="addDomain">New domain</el-button>
|
|
<el-button @click="resetForm('dynamicValidateForm')">Reset</el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
export default {
|
|
data() {
|
|
return {
|
|
dynamicValidateForm: {
|
|
domains: [
|
|
{
|
|
key: 1,
|
|
value: '',
|
|
},
|
|
],
|
|
email: '',
|
|
},
|
|
}
|
|
},
|
|
methods: {
|
|
submitForm(formName) {
|
|
this.$refs[formName].validate((valid) => {
|
|
if (valid) {
|
|
alert('submit!')
|
|
} else {
|
|
console.log('error submit!!')
|
|
return false
|
|
}
|
|
})
|
|
},
|
|
resetForm(formName) {
|
|
this.$refs[formName].resetFields()
|
|
},
|
|
removeDomain(item) {
|
|
const index = this.dynamicValidateForm.domains.indexOf(item)
|
|
if (index !== -1) {
|
|
this.dynamicValidateForm.domains.splice(index, 1)
|
|
}
|
|
},
|
|
addDomain() {
|
|
this.dynamicValidateForm.domains.push({
|
|
key: Date.now(),
|
|
value: '',
|
|
})
|
|
},
|
|
},
|
|
}
|
|
</script>
|