1
2
3
4
5
//方法1:
if(window.location.pathname.includes("/")){console.log("HomePage");}
 
//方法2:(返回值>-1即找到,不是0)
if(window.location.pathname.indexOf("/")>-1){console.log("HomePage");}