修改MdInput的demo,使之能展现验证功能

This commit is contained in:
lei.jiang 2017-09-16 22:05:57 +08:00 committed by 花裤衩
parent 8945476c22
commit fde12e8ef9
1 changed files with 23 additions and 6 deletions

View File

@ -1,9 +1,11 @@
<template> <template>
<div class="components-container"> <div class="components-container">
<div class='component-item'> <div class='component-item'>
<md-input name="name" v-model="title" required :maxlength="100"> <el-form :model="demo" :rules="demoRules">
标题 <el-form-item prop="title">
</md-input> <md-input icon="search" name="title" placeholder="输入标题" v-model="demo.title">标题</md-input>
</el-form-item>
</el-form>
<code class='code-part'>Material Design 的input</code> <code class='code-part'>Material Design 的input</code>
</div> </div>
@ -22,18 +24,33 @@
</template> </template>
<script> <script>
import MdInput from '@/components/MDinput'
import PanThumb from '@/components/PanThumb' import PanThumb from '@/components/PanThumb'
import MdInput from '@/components/MDinput'
import waves from '@/directive/waves.js' // import waves from '@/directive/waves.js' //
export default { export default {
components: { MdInput, PanThumb }, components: {
PanThumb,
MdInput
},
directives: { directives: {
waves waves
}, },
data() { data() {
const validate = (rule, value, callback) => {
if (value.length !== 6) {
callback(new Error('请输入六个字符'))
} else {
callback()
}
}
return { return {
demo: {
title: '' title: ''
},
demoRules: {
title: [{ required: true, trigger: 'change', validator: validate }]
}
} }
} }
} }