Blogger Information
Blog 28
fans 0
comment 0
visits 65280
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
element ui级联选择器--表单验证
蒸蒸
Original
1125 people have browsed it

一、vue模板表单内容
注意el-form元素的model属性与el-cascader元素的v-model之间的对应关系,以及el-form-item的prop与el-cascader元素的v-model之间的对应关系

  1. <el-form :inline="true" :rules="rules" ref="form" :model="form">
  2. <el-form-item prop="origin">
  3. <el-cascader :options="originOptions" clearable placeholder="请选择始发地" v-model="form.origin"
  4. :props="{ expandTrigger: 'hover' }" filterable></el-cascader>
  5. </el-form-item>
  6. <el-form-item>
  7. <i class="el-icon-right"></i>
  8. </el-form-item>
  9. <el-form-item prop="desti">
  10. <el-cascader :options="destiOptions" clearable placeholder="请选择目的地" v-model="form.desti"
  11. :props="{ expandTrigger: 'hover' }" filterable></el-cascader>
  12. </el-form-item>
  13. <el-form-item>
  14. <el-button type="primary" icon="el-icon-search" style="margin-left:20px;">查运价</el-button>
  15. </el-form-item>
  16. </el-form>

二、javascript代码部分
rules中的origin与desti与el-form-item元素的prop相对应

  1. export default {
  2. name: "Truckprice",
  3. data() {
  4. return {
  5. form:{
  6. origin:'',
  7. desti:''
  8. },
  9. rules:{
  10. origin:[
  11. {required: true, message: '请选择始发地', trigger: 'change'},
  12. ],
  13. desti:[
  14. {required: true, message: '请选择目的地', trigger: 'change'},
  15. ]
  16. }
  17. }
  18. }
  19. }
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post