el-dialog 添加loading;avue-form 表单插槽

效果:

第一步:custom-class="publishDialog" 新起一个类名

html 复制代码
 <el-dialog title="发布配置" custom-class="publishDialog" :visible.sync="publishDialogVisible" width="800px" :append-to-body="true"
            :before-close="publishHandleClose">
            <avue-form :option="option" v-model="publishForm" ref="publishForm" @submit="handleSubmit">
                <template slot-scope="{}" slot="layerNameLabel">
                    <span>图层别名&nbsp;&nbsp;</span>
                    <el-tooltip class="item" effect="dark" content="仅支持输入字母、数字" placement="top-start">
                        <i class="el-icon-warning"></i>
                    </el-tooltip>
                </template>
                <template slot-scope="{size}" slot="menuForm" style="text-align: right;">
                    <el-button :size="size" @click="publishHandleClose">取 消</el-button>
                    <el-button type="primary" :size="size" @click="$refs.publishForm.submit()">确 定</el-button>
                </template>
            </avue-form>

        </el-dialog>

第二步:

定义触发loading的方法

let loadingInstance = Loading.service(
{
target: '.publishDialog', (dialog的新类名 也就loading遮罩的dom)
lock: true,
text: '加载中',
}
);

关闭loading的方法

loadingInstance.close();

javascript 复制代码
  handleSubmit(form, done) {
            let loadingInstance = Loading.service(
                {
                    target: '.publishDialog',
                    lock: true,
                    text: '加载中',
                }
            );
            release().then(res => {
                if (res.data.code == 200) {
                    this.$message({
                        type: 'success',
                        message: '发布成功!'
                    });
                    loadingInstance.close();
                    this.publishDialogVisible = false
                    done()
                } else {
                    loadingInstance.close();
                }
            })
        },

补充:avue-form 表单插槽

效果:

第一步:slot="layerNameLabel"

html 复制代码
           <avue-form :option="option" v-model="publishForm" ref="publishForm" @submit="handleSubmit">
                <template slot-scope="{}" slot="layerNameLabel">
                    <span>图层别名&nbsp;&nbsp;</span>
                    <el-tooltip class="item" effect="dark" content="仅支持输入字母、数字" placement="top-start">
                        <i class="el-icon-warning"></i>
                    </el-tooltip>
                </template>
            </avue-form>

第二步:labelslot: true

javascript 复制代码
                   {
                        label: "图层别名",
                        prop: "layerName",
                        labelslot: true,
                        rules: [{
                            required: false,
                            message: "请输入数据库名",
                            trigger: "blur"
                        }, {
                            message: "只能输入字母、数字",
                            pattern: /^[a-zA-Z0-9]+$/,
                            trigger: "blur"
                        }
                        ],
                    },
相关推荐
zyfts24 分钟前
🔥告别 20 分钟等待!NestJS 生产级消息队列 BullMQ 实践指南
前端·后端
GISer_Jing33 分钟前
3DThreeJS渲染核心架构深度解析
javascript·3d·架构·webgl
狗头大军之江苏分军37 分钟前
【压力】一位一线炼钢工人的消失
前端·后端
摇滚侠39 分钟前
Vue 项目实战《尚医通》,完成订单详情静态的搭建,笔记47
vue.js·笔记
拉不动的猪1 小时前
文件下载:后端配置、前端方式与进度监控
前端·javascript·浏览器
Amy_yang1 小时前
前端实现 Server-Sent Events 全解析:从代码到调试的实战指南
前端·uni-app
sean聊前端1 小时前
听说vite要一统江湖了,我看看怎么个事
前端
喝二两啤酒1 小时前
手把手打通 H5 多支付通道(Apple pay、Google pay、第三方卡支付)
前端
特级业务专家1 小时前
续集:Vite 字体插件重构之路 —— 从“能用”到“生产级稳定”
javascript·vue.js·vite
gongzemin1 小时前
约课小程序增加候补功能
前端·微信小程序·小程序·云开发