JS中判断某个字符串是否包含另一个字符串的五种方法 String对象的方法方法一:indexOf() (推荐)varstr="123"console.log(str.indexOf("2")!=-1);//trueindexOf( js中判断字符串包含