js怎么验证字符串中是否有空格?var str = "任意 字符串"if (str.indexOf(" ") == -1) { alert("没有空格")} else { alert("有空2023-03-05JavaScript110