像本地开发中经常需要匹配localhost和127.0.0.1
我们就可以使用:
/(localhost|127.0.0.1)/.test(location.hostname)
这里用括号代表一个整体,如果用的中括号[],就是别的意思了
/[localhost|127.0.0.1]/.test(location.hostname)
这个代表只要可以匹配中括号的任意一个字符就好了,包括'|'、1、2、0、7等
像本地开发中经常需要匹配localhost和127.0.0.1
我们就可以使用:
/(localhost|127.0.0.1)/.test(location.hostname)
这里用括号代表一个整体,如果用的中括号[],就是别的意思了
/[localhost|127.0.0.1]/.test(location.hostname)
这个代表只要可以匹配中括号的任意一个字符就好了,包括'|'、1、2、0、7等
958
786
3万+

被折叠的 条评论
为什么被折叠?