问题描述:
Uncaught TypeError: Cannot read property 'indexOf' of null
问题分析:
使用indexOf()的变量为null。
问题解决:
1、使用indexOf()之前,先判断使用indexOf()的变量是否为null。
var str=null;
if(str!=null&&str.indexOf("1")>-1){
alert("包含1");
}2、检查使用indexOf()的变量为什么会为null。
版权声明:本文为qq_38974638原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。
https://space.bilibili.com/484264966?spm_id_from=333.1007.0.0