Vue Element-ui弹窗 this.$alert is not a function

使用问题

Element-ui官网上单独引用MessageBox的话需要在import中加入MessageBox。

Vue+Element-ui弹窗 this.$alert is not a function问题

但是在使用时报了this.$alert is not a function

Vue+Element-ui弹窗 this.$alert is not a function问题

解决办法

在element.js中加入Vue.prototype.$XXX = MessageBox

Vue+Element-ui弹窗 this.$alert is not a function问题

在使用时用this. $XXX.alert

Vue+Element-ui弹窗 this.$alert is not a function问题

Vue element-ui 弹窗使用遇到的问题

弹窗里定义了表单使用遇到关闭弹窗再次开启时会自动保存上一次的数据而不是重置初始数据的问题

解决代码如下

<template>
    <el-form-item label>
        <el-button :loading="state" type="primary" @click="onSubmit('ruleForm')">保存</el-button>
        <el-button @click="handleClose('ruleForm')">取消</el-button>
    </el-form-item>
</template>
 
 
<script>
export default {
    methods:{        
        handleClose(formName) {
            this.$refs[formName].resetFields();  //这句代码重置弹窗里定义的表单数据
        }
    }
}
</script>

以上为个人经验,希望能给大家一个参考,也希望大家多多支持。

原文地址:https://blog.csdn.net/weixin_45429941/article/details/115707404

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-01
猜你喜欢
  • 2021-08-09
  • 2022-12-23
  • 2022-01-18
  • 2021-07-08
  • 2022-12-23
  • 2021-06-21
  • 2022-12-23
相关资源
相似解决方案