Css javaSript常见错误

1,css常见错误

  1. css //注释不管用

  2. 上一行发生错误,下一行css也不管用

如果审查元素,没有发现你的的css

  1. css引入发生错误

  2. css选择器发生错误

如果审查元素发现你写的css,被划掉了

被划掉带感叹号,css语法错误

单纯比划掉,选择器权限不够

2.js错误汇总

1.SyntaxError(语法错误

解析代码时发生的语法错误

eg:var 1a;

  Uncaught SyntaxError: Unexpected number

2.ReferenceError(引用错误)

a.引用了一个不存在的变量

eg: console.log(a);

  Uncaught ReferenceError: a is not defined

b.将变量赋值给一个无法被赋值的对象

eg:console.log()= 1;

  Uncaught ReferenceError: Invalid left-hand side in assignment

3.RangeError(范围错误)

超出有效范围

eg:var a= new Array(-1);

  Uncaught RangeError: Invalid array length

4.TypeError(类型错误)

a.变量或参数不是预期类型,比如,对字符串、布尔值、数值等原始类型的值使用new命令,就会抛出这种错误,因为new命令的参数应该是一个构造函数。

eg: var a= new 123;

  Uncaught TypeError: 123 is not a function

b.调用对象不存在的方法

eg:var a;a.aa();

  Uncaught TypeError: Cannot read property 'aa' of undefined

  

5.URLError(URL错误)

与url相关函数参数不正确,主要是encodeURI()、decodeURI()、encodeURIComponent()、decodeURIComponent()、escape()和unescape()这六个函数。

eg: decodeURI('%2')

  Uncaught URIError: URI malformed

6.EvalError(eval错误)

eval函数没有被正确执行

3,js常见错误案例

Uncaught ReferenceError: b is not defined

未捕捉到引用错误:b 没有定义

(没有定义就去使用它了)

Uncaught SyntaxError: Invalid or unexpected token

25行发生的错误

Uncaught 没有捕捉到

SyntaxError:语法错误

Invalid不合法的

or或者

Unexpected 不期待出现的

token字符

哥们25行语法错误,标点符号错误

script写过src属性的不能在里面放入代码

常见错误.html:20 Uncaught TypeError: swiper.clone is not a function

9186f5f4e8267de694807ea0ac891eba.png

20行发生了错误

uncaught TypeError没有捕捉到类型错误

: swiper.clone is not a function

.swiper.clone不是一个函数

swiper没有clone方法 大概率方法名写错了

Uncaught TypeError: Cannot read properties of null (reading 'appendChild')

appendChild前面那个元素为null

<script>
    var swiper = document.querySelector(".swiepr");
   document.body.appendChild(swiper.clone(true))
</script>
	</head>
	<body>

document.body为null

原因:在body前获去执行js document.body 还没有body标签

常见错误.html:15 Uncaught TypeError: Cannot read properties of undefined (reading 'add')

15行发生错误

Uncaught TypeError没有捕捉到类型错误

Cannot read properties of undefined 不能读取未定义的属性

(reading 'add')读取add属性

add前面那个对象是undefined

原因:swiper.classList 选择到swiper没有classList的值为undefined

通过querySelectAll选择的 列表没有classList属性

Uncaught TypeError: Cannot read properties of null (reading 'classList')

classList前面那个元素为null 没有选择到

常见错误.html文件的15行,第11字符错误

Uncaught 没有捕捉到

TypeError类型错误

Cannot 不能

read 读

properties 属性

of null null的

不能读取null的属性(reading ‘classList’)

reading读

classList 类列表

当读取null的classList属性了发送了类型错误

引起的原因: swiper选择适合没有选择到值就null(选择器填错了)

Uncaught SyntaxError: Unexpected token '<'

swiper.js出错了,还在第1行

uncaught没有捕捉到

SyntaxError 语法错误

Unexpected 不期待的

token符号

‘<’ 不应存在

引起原因:script的src 地址填错了,hbuilderx默认返回一个404的网页

js文件是个html待'<' 报错

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值