JS和CSS常见错误

CSS错误

1、css 用“//”注释不能用。例 //width=100px;

2、上一行发生错误,下一行css不能够被执行。

3、如果审查元素,没有发现css文件

● css引入发生错误

● css选择器发生错误

4、如果审查元素,发现css被划了一道横线

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

●只有一条横线,选择器权限不够

JS常见错误

1、Uncaught ReferenceError: b is not defined

html第27行--未捕捉到引用错误:b 没有定义(没有定义就去使用了)

2、Uncaught SyntaxError: Invalid or unexpected token

Uncaught 没有捕捉到

SyntaxError:语法错误

Invalid不合法的

Unexpected 不期待出现的

token字符

html中第25行语法错误,标点符号错误

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

uncaught TypeError没有捕捉到类型错误

: swiper.clone is not a function

.swiper.clone不是一个函数

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

4、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标签

5、html:15 Uncaught TypeError: Cannot read properties of undefined (reading 'add')

Uncaught TypeError没有捕捉到类型错误

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

(reading 'add')读取add属性

add前面那个对象是undefined

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

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

6、Uncaught SyntaxError: Unexpected token '<'

 SyntaxError 语法错误

‘<’ 不应存在

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

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

7、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(选择器填错了)

猜你喜欢

转载自blog.csdn.net/topuu/article/details/124972675
今日推荐