WishMeLz

生活其实很有趣

浏览器内核判断

const userAgent = navigator.userAgent;
const isWechat = /MicroMessenger/.test(userAgent);
const isAlipay = /AlipayClient/.test(userAgent);
const isChrome = /Chrome/.test(userAgent) && /Google Inc/.test(navigator.vendor);
const isFirefox = /Firefox/.test(userAgent);
const isSafari = /Safari/.test(userAgent) && /Apple Computer/.test(navigator.vendor);
const isEdge = /Edg/.test(userAgent);
const isIE = /Trident/.test(userAgent);