element-plus丑陋的使用
<template> <div> <el-form :model="form" :rules="rules" ref="form" label-width="100px"> <el-form-item label="时间"> <el-date-picker v-model="form.time" type="datetime" placeholder="选择时间"></el-date-picker> </el-form-item> <el-form-item label="地点"> <el-input v-model="form.location" placeholder="请输入地点"></el-input> </el-form-item> <el-form-item label="所目睹事件的经过"> <el-input type="textarea" v-model="form.description" placeholder="请输入事件描述"></el-input> </el-form-item> <el-form-item label="霸凌者信息"> <el-input v-model="form.bullyInfo" placeholder="选填"></el-input> </el-form-item> <el-form-item label="被霸凌者信息"> <el-input v-model="form.victimInfo" placeholder="选填"></el-input> </el-form-item> <el-form-item label="其他重要信息"> <el-input type="textarea" v-model="form.otherInfo" placeholder="请输入其他重要信息"></el-input> </el-form-item> <el-form-item label="上传照片或视频"> <el-upload action="#" list-type="picture-card" :on-preview="handlePictureCardPreview" :onRemove="handleRemove" > <i class="el-icon-plus"></i> </el-upload> </el-form-item> <el-form-item> <el-button type="primary" @click="submitForm">立即举报</el-button> </el-form-item> </el-form> <el-dialog :title="'确认提交'" :visible.sync="dialogVisible"> <span>是否确认提交举报信息?</span> <span slot="footer" class="dialog-footer"> <el-button @click="dialogVisible = false">取消</el-button> <el-button type="primary" @click="confirmSubmit">确定</el-button> </span> </el-dialog> </div> </template> <script lang="ts" setup> import { ref } from 'vue'; import { ElDatePicker, ElInput, ElUpload, ElButton, ElDialog } from 'element-plus'; const form = ref({ time: '', location: '', description: '', bullyInfo: '', victimInfo: '', otherInfo: '' }); const rules = ref({ time: [{ required: true, message: '请选择时间', trigger: 'change' }], location: [{ required: true, message: '请输入地点', trigger: 'blur' }], description: [{ required: true, message: '请输入事件描述', trigger: 'blur' }] }); const dialogVisible = ref(false); const submitForm = () => { dialogVisible.value = true; }; const confirmSubmit = () => { // 在此处处理提交逻辑 dialogVisible.value = false; }; const handlePictureCardPreview = (file: any) => { // 处理预览图片逻辑 }; const handleRemove = (file: any) => { // 处理移除图片逻辑 }; </script> <style scoped> .dialog-footer { text-align: center; padding: 10px 0; } </style>