Vue TypeError: this.$confirm is not a function 2022-12-23 06:24 227阅读 0赞 ## 错误 ## 在使用element ui,采用局部引入时候,报错`TypeError: this.$confirm is not a function`。 ![在这里插入图片描述][watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2xpYW5naGVjYWk1MjE3MTMxNA_size_16_color_FFFFFF_t_70_pic_center] 因为没有在vue的实例上挂载 c o n f i r m 和 confirm和 confirm和message导致的报错 ## 解决方案 ## 修改element.js文件: 1 引入messageBox 插件 > import \{MessageBox\} from ‘element-ui’ 2 在vue 的原型对象上挂载confirm > Vue.prototype.$confirm = MessageBox.confirm 如下图所示: ![在这里插入图片描述][watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2xpYW5naGVjYWk1MjE3MTMxNA_size_16_color_FFFFFF_t_70_pic_center 1] 以后就可以放心的在vue中的任何文件使用this. c o n f i r m 或 者 t h i s . confirm或者this. confirm或者this.message了。比如:你想用MessageBox中的confirm方法,现在可以这样用: <template> <div> <el-button type="text" @click="dialogVisible = true">点击打开 Dialog</el-button> <el-dialog title="提示" :visible.sync="dialogVisible" width="30%" :before-close="handleClose"> <span>这是一段信息</span> <span slot="footer" class="dialog-footer"> <el-button @click="dialogVisible = false">取 消</el-button> <el-button type="primary" @click="dialogVisible = false">确 定</el-button> </span> </el-dialog> </div> </template> <script> export default { data () { return { dialogVisible: false } }, methods: { handleClose (done) { const _this = this _this.$confirm('确认关闭?') .then(_ => { done() }) .catch(_ => { }) } } } </script> [watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2xpYW5naGVjYWk1MjE3MTMxNA_size_16_color_FFFFFF_t_70_pic_center]: /images/20221120/adc3812f17fa444d96a474372c820cf7.png [watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2xpYW5naGVjYWk1MjE3MTMxNA_size_16_color_FFFFFF_t_70_pic_center 1]: /images/20221120/6ee72ec9d0c84f18978066ac2dedc6b2.png
相关 Uncaught TypeError: xxx is not a function 原文地址:[https://blog.csdn.net/u011870547/article/details/52765811][https_blog.csdn.net_u01 ╰半夏微凉°/ 2023年11月22日 06:51/ 0 赞/ 21 阅读
相关 Vue TypeError: this.$confirm is not a function 错误 在使用element ui,采用局部引入时候,报错`TypeError: this.$confirm is not a function`。 ![在这里插入图片 Dear 丶/ 2022年12月23日 06:24/ 0 赞/ 228 阅读
相关 TypeError: dateObject.getTime is not a function 在使用ElementUI的日期选择组件el-date-picker时,报错: ![在这里插入图片描述][20201106183707500.png_pic_center] Bertha 。/ 2022年12月19日 09:28/ 0 赞/ 175 阅读
相关 Uncaught TypeError: XXX.getTime is not a function 因为变量只是字符串,无法调用日期函数。 你应该解析它们以获得一个`Date`对象,对于该格式我总是使用以下函数: // parse a date in yyyy-m 淡淡的烟草味﹌/ 2022年09月27日 09:16/ 0 赞/ 304 阅读
相关 Uncaught TypeError: $(...).customFileInput is not a function 1、错误描述 demo.js:214 Uncaught TypeError: $(...).customFileInput is not a function 你的名字/ 2022年06月10日 05:18/ 0 赞/ 183 阅读
相关 TypeError: $(...).form is not a function 这两天在做图片上传的时候遇到了一个问题,通过$(...).form初始化form表单时总是报TypeError: $(...).form is not a function 红太狼/ 2022年06月05日 06:38/ 0 赞/ 103 阅读
相关 TypeError: db.collection is not a function 1、错误描述 F:\nodejs>node insertData.js (node:10028) DeprecationWarning: current UR 比眉伴天荒/ 2022年05月16日 00:11/ 0 赞/ 222 阅读
相关 TypeError:e.indexOf is not a function 更换jquery为最新版本jquery3.3.1报错,报错信息如下: ![在这里插入图片描述][watermark_type_ZmFuZ3poZW5naGVpdGk_sha 亦凉/ 2022年04月03日 12:56/ 0 赞/ 250 阅读
相关 TypeError: "_vm.onetopic is not a function" 解决方案 1、方法 onetopic要放在methods:\{\}里面 2、看看自己是不是多个\},导致方法在methods:\{\}外面了 ------------ 浅浅的花香味﹌/ 2022年02月01日 03:15/ 1 赞/ 273 阅读
相关 TypeError: instance.render is not a function 1、错误描述 ![watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly95b3VoYWlkb25nLmJs 旧城等待,/ 2022年01月28日 15:39/ 0 赞/ 239 阅读
还没有评论,来说两句吧...