JS判断字符串中是否存在某个字符 JS 判断字符串中是否存在某个字符可以用 String 中的 indexOf() 12345678let str = 'abcd'if (str.indexOf('a') == -1) { //等于-1表示这个字符串中没有a这个字符 console.log('不含这个字符')} else { console.log('含有这个字符')} js #js #utils JS中数组的常用方法 上一篇 keep-alive基本使用 下一篇 Please enable JavaScript to view the comments