解决sweetalert 无故报错 elem.className.replace Uncaught TypeError: Cannot read property 'className' of null

简介: 今天碰到这么一个问题,在使用sweetalert的时候时有时无会报错 elem.className.replace Uncaught TypeError: Cannot read property 'className' of null 很简单,debug源码,发现elem在有时候会为空,为空的...

今天碰到这么一个问题,在使用sweetalert的时候时有时无会报错

 elem.className.replace Uncaught TypeError: Cannot read property 'className' of null

 很简单,debug源码,发现elem在有时候会为空,为空的时候抛出异常,修改如下代码即可解决该问题

 效果:

 

相关文章
|
9月前
|
容器
Echarts报错 Cant read property getWidth of null的解决方案
Echarts报错 Cant read property getWidth of null的解决方案
80 0
|
7月前
【已解决】TypeError: Cannot destructure property `createHash` of ‘undefined‘ or ‘null‘
【已解决】TypeError: Cannot destructure property `createHash` of ‘undefined‘ or ‘null‘
179 1
|
6月前
|
JavaScript API
【Vue】Cannot set reactive property on undefined,null,or primitive value:undefined
【Vue】Cannot set reactive property on undefined,null,or primitive value:undefined
88 0
|
6月前
|
缓存 关系型数据库 MySQL
【异常解决】缓存报错:Null key returned for cache operation (maybe you are using named params on classes withou
【异常解决】缓存报错:Null key returned for cache operation (maybe you are using named params on classes withou
199 0
|
3月前
|
Java
Error:(15, 13) java: No property named “id” exists in source parameter(s). Did you mean “null”?
Error:(15, 13) java: No property named “id” exists in source parameter(s). Did you mean “null”?
29 1
|
9月前
|
Java 数据库连接 mybatis
There is no getter for property named ‘null‘ in ‘class
There is no getter for property named ‘null‘ in ‘class
114 0
There is no getter for property named ‘null‘ in ‘class
|
4月前
|
JavaScript API
Property ‘proxy‘ does not exist on type ‘ComponentInternalInstance | null‘.ts
Property ‘proxy‘ does not exist on type ‘ComponentInternalInstance | null‘.ts
|
5月前
|
JavaScript
TypeError: Cannot read properties of null (reading 'level')
# 一、分析问题 1、一个下拉框组件的更新由另一个下拉框组件控制被动更新列表,子级下拉框的值是由父级下拉框的值调用接口获取,每次父级下拉框值的改变都会改变子级下拉框的数据源也就是会改变子级下拉框的options,切换后之前的父级节点找不到就会报了这个错,父级节点不改变(即不切换)的话不会报错 # 二、解决方案 ## 1、vue页面的html层 ```html <div> <el-row :gutter="15"> <el-col :span="4"> <div">父级下拉框:</div> <el-select clearable v-model="parentId" @c
78 0
|
6月前
|
缓存 Cloud Native JavaScript
猫头虎的技术博客:解决npm报错 npm ERR! Cannot read properties of null (reading ‘pickAlgorithm‘)报错问题
猫头虎的技术博客:解决npm报错 npm ERR! Cannot read properties of null (reading ‘pickAlgorithm‘)报错问题
107 0
|
9月前
|
JavaScript
解决npm ERR! Cannot read properties of null (reading ‘pickAlgorithm‘)报错问题
在vue项目中,使用npm i 命令安装node modules时,出现报错。