prevent dispatch form event
when component import an Input, prevent dispatch event from Input to Form
This commit is contained in:
parent
4a5d5cc9f2
commit
21dad188c1
8 changed files with 92 additions and 54 deletions
|
@ -1,35 +1,48 @@
|
|||
<template>
|
||||
<i-form ref="formInline" :model="formInline" :rules="ruleInline" inline>
|
||||
<Form-item prop="user">
|
||||
<Input type="text" v-model="formInline.user" placeholder="Username">
|
||||
<Icon type="ios-person-outline" slot="prepend"></Icon>
|
||||
</Input>
|
||||
</Form-item>
|
||||
<Form-item prop="password">
|
||||
<Input type="password" v-model="formInline.password" placeholder="Password">
|
||||
<Icon type="ios-locked-outline" slot="prepend"></Icon>
|
||||
</Input>
|
||||
</Form-item>
|
||||
<Form-item>
|
||||
<Button type="primary" @click.native="handleSubmit('formInline')">登录</Button>
|
||||
</Form-item>
|
||||
</i-form>
|
||||
<div>
|
||||
date: {{ formInline.date }}
|
||||
<i-form ref="formInline" :model="formInline" :rules="ruleInline">
|
||||
<Form-item prop="date">
|
||||
<Date-picker type="date" placeholder="选择日期" v-model="formInline.date"></Date-picker>
|
||||
</Form-item>
|
||||
<Form-item prop="user">
|
||||
<Input v-model="formInline.user">
|
||||
</Form-item>
|
||||
<Form-item>
|
||||
<i-button type="primary" @click.native="handleSubmit('formInline')">登录</i-button>
|
||||
</Form-item>
|
||||
</i-form>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
formInline: {
|
||||
user: '',
|
||||
password: ''
|
||||
date: new Date(),
|
||||
user: ''
|
||||
},
|
||||
ruleInline: {
|
||||
user: [
|
||||
{ required: true, message: '请填写用户名', trigger: 'blur' }
|
||||
date: [
|
||||
{
|
||||
required: true,
|
||||
type: 'date',
|
||||
message: '请选择日期',
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
password: [
|
||||
{ required: true, message: '请填写密码', trigger: 'blur' },
|
||||
{ type: 'string', min: 6, message: '密码长度不能小于6位', trigger: 'blur' }
|
||||
user: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入',
|
||||
trigger: 'change',
|
||||
min: 10
|
||||
},
|
||||
{
|
||||
required: true,
|
||||
message: '请输入2',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -38,11 +51,14 @@
|
|||
handleSubmit(name) {
|
||||
this.$refs[name].validate((valid) => {
|
||||
if (valid) {
|
||||
console.log('success');
|
||||
this.$Message.success('提交成功!');
|
||||
} else {
|
||||
console.log('fail')
|
||||
this.$Message.error('表单验证失败!');
|
||||
}
|
||||
})
|
||||
},
|
||||
handleInput (val) {
|
||||
console.log(val)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,22 @@
|
|||
<template>
|
||||
<i-button @click.native="time">显示一个10秒的提示</i-button>
|
||||
<div>
|
||||
<i-button @click.native="success">显示成功提示</i-button>
|
||||
<i-button @click.native="warning">显示警告提示</i-button>
|
||||
<i-button @click.native="error">显示错误提示</i-button>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
methods: {
|
||||
time () {
|
||||
this.$Message.info('我将在10秒后消失', 3, () => {
|
||||
console.log(1111)
|
||||
});
|
||||
success () {
|
||||
this.$Message.success('这是一条成功的提示');
|
||||
},
|
||||
warning () {
|
||||
this.$Message.warning('这是一条警告的提示');
|
||||
},
|
||||
error () {
|
||||
this.$Message.error('对方不想说话,并且向你抛出了一个异常');
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
this.$Message.config({
|
||||
top: 50,
|
||||
duration: 3
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue