zoukankan      html  css  js  c++  java
  • Element-ui 中dialog的使用方法

    <template>
      <div>
        <el-button type="text" @click="dialogFormVisible = true">打开嵌套表单的 Dialog</el-button>
    
        <el-dialog title="收货地址" :visible.sync="dialogFormVisible"  @closed="handleClose">
          <el-form :model="form" :rules="rules" ref="ruleForm">
            <el-form-item label="活动名称" :label-width="formLabelWidth" prop="name">
              <el-input v-model="form.name" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="活动区域" :label-width="formLabelWidth">
              <el-select v-model="form.region" placeholder="请选择活动区域">
                <el-option label="区域一" value="shanghai"></el-option>
                <el-option label="区域二" value="beijing"></el-option>
              </el-select>
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click="dialogFormVisible = false">取 消</el-button>
            <el-button type="primary" @click="handleSave">确 定</el-button>
          </div>
        </el-dialog>
      </div>
    </template>
    
    <script>
    export default {
      data () {
        return {
          dialogFormVisible: false,
          form: {
            name: '',
            region: '',
            date1: '',
            date2: '',
            delivery: false,
            type: [],
            resource: '',
            desc: ''
          },
          formLabelWidth: '120px',
          rules: {
            name: [
              { required: true, message: '请输入活动名称', trigger: 'blur' },
              { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
            ]
          }
        }
      },
    
      methods: {
        handleClose () {
          this.$refs.ruleForm.resetFields()
          this.form = {
            name: '',
            region: '',
            date1: '',
            date2: '',
            delivery: false,
            type: [],
            resource: '',
            desc: ''
          }
        },
        handleSave () {
          this.$refs.ruleForm.validate((valid) => {
            if (valid) {
              console.log('输入正确')
              this.dialogFormVisible = false
            } else {
              console.log('输入错误')
            }
          })
        }
      }
    }
    </script>
    
    <style lang="less" scoped>
    
    </style>
  • 相关阅读:
    MIne FirstBlog
    P6563 [SBCOI2020]一直在你身旁
    P6563 [SBCOI2020]一直在你身旁
    T122085 [SBCOI2020]时光的流逝
    LC 918. Maximum Sum Circular Subarray
    1026 Table Tennis
    LC 1442. Count Triplets That Can Form Two Arrays of Equal XOR
    LC 1316. Distinct Echo Substrings
    LC 493. Reverse Pairs
    1029 Median (二分)
  • 原文地址:https://www.cnblogs.com/wuxianqiang/p/10018575.html
Copyright © 2011-2022 走看看