pc端开发时,须要在/etc/hosts里配置各类本地环境;当开发移动的界面时,除了使用浏览器的"手机模式"查看效果,还能够直接使用手机进行查看。可是修改手机的/etc/hosts就比较麻烦了。java
brew install dnsmasqmacos
配置文件位置:/usr/local/etc/dnsmasq.conf
浏览器
端口 port=53(默认值) 上游dns服务配置读取 resolv-file=/etc/resolv.conf 读取/etc/hosts里的配置 addn-hosts=/etc/hosts 监听地址,127.0.0.1和局域网地址都必须设置;这两个都是dnsmasq的dns服务器地址,127.0.0.1是方便本地测试使用的 listen-address=127.0.0.1,x.x.x.x(本机的局域网地址)
sudo brew services start/stop/restart dnsmasq(macOS 使用sudo 启动,否则没法生效)服务器