WishMeLz

生活其实很有趣

分类 ts 下的文章

浏览器内核判断

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); con...

decimal.js 加减乘除

import Decimal from 'decimal.js'; // 加法 function add(...nums: number[]): number { return nums.reduce((total, num) => new Decimal(total).plus(num), 0).toNumber(); } // 减法 function subtract(...nums: number[]): number { return nums.reduce((total, num) => new Decimal(t...