npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mtjs/utils

v0.1.45

Published

utils for qie projects

Downloads

151

Readme

utils

参考: https://github.com/RayAiden/ts-utils

JS 常用工具类

各种常用的 JS 工具集

npm i @mtjs/utils -S

DateUtils

  • formatDate
  • formatISODate
  • formatISOTime
  • formatISODateTime
  • insureDate
  • getLastDayOfMonth
  • getBeginningOfDate
  • getEnddingOfDate

formatDate

日期格式化 formatDate(date: Date | number | string, format?: string): string

  • 参数: dateValue 时间戳 | 日期字符串
  • 参数: formatString yyyyMMdd mm:hh:ss
formatDate(new Date().getTime(), "yyyy/MM/dd hh:mm:ss"); // "2019/11/06 15:31:50"

formatISODate

获取标准日期 formatISODate(date: number | string | Date): string

date: 时间戳 | 日期字符串 | 日期对象

formatISODate(new Date()); // 2019-11-06

formatISOTime

获取标准时间 formatISOTime(date: number | string | Date): string

date: 时间戳 | 日期字符串 | 日期对象

formatISOTime(new Date()); // 07:27:33

formatISODateTime

获取标准日期和时间 formatISODateTime(date: number | string | Date): string

date: 时间戳 | 日期字符串 | 日期对象

formatISODateTime(new Date()); // 2019-11-06 07:27:33

insureDate

得到时间对象 insureDate(date: number | string | Date): Date

date: 时间戳 | 日期字符串 | 日期对象

insureDate(new Date()); // 2020-08-25T16:00:00.000Z

getLastDayOfMonth

获取当月的最后一天 getLastDayOfMonth(year = new Date().getFullYear(), month = new Date().getMonth())

year: 时间戳 month: 时间戳

getLastDayOfMonth('2020','8'); // '2020-8-31'

getBeginningOfDate

获取一天开始(00:00:00)的日期对象 getBeginningOfDate (date: number | string | Date, ISOString: Boolean): string

date: 时间戳 | 日期字符串 | 日期对象 ISOString: 是否使用 ISO 标准返回 Date 对象的字符串格式 | Boolean

getBeginningOfDate(1598343480735, true) // "2020-08-24T16:00:00.000Z"
getBeginningOfDate(1598343480735, false) // '2020-08-25 00:00:00'

getEnddingOfDate

得到时间对象 getEnddingOfDate (date: number | string | Date, ISOString: Boolean): string

date: 时间戳 | 日期字符串 | 日期对象 ISOString: 是否使用 ISO 标准返回 Date 对象的字符串格式 | Boolean

getEnddingOfDate(1598343480735, true) // "2020-08-24T16:00:00.000Z"
getEnddingOfDate(1598343480735, false) // '2020-08-25 23:59:59'

DOMUtils

  • scrollTop
  • raf
  • cancelRaf

scrollTop

滚动到顶部 scrollTop(el: HTMLElement | Window, from = 0, to: number, duration = 500, endCallback: Function)

el: 需要滚动的元素 | HTMLElement | Window, from: 滚动开始的位置 | 0, to: 滚动终止的位置, duration: 滚动持续的时间 | 500, endCallback: 滚动完成之后的回调函数

NumberUtils

  • numeral
  • randomNum
  • toFixedNum
  • toDecimalMark
  • epsEqDecimal
  • px2vw
  • vw2Px
  • kb2mb
  • formatPrice
  • unFormat
  • formatNum
  • add
  • sub
  • mul
  • div
  • byte2mb
  • toPercent
  • formatMoney
  • formatWeek

randomNum

返回指定范围内的随机整数 randomNum(min: number, max: number): number

min: 最小值 max: 最大值

randomNum(5,10) // => 5 || 6 || 7 || 8 || 9 || 10

toFixedNum

将数字四舍五入到指定的小数位数 toFixedNum(n: number, decimals = 0): number

n: 操作的数字 decimals: 精确到几位小数

round(12.555,2) // => 12.56

toDecimalMark

将数字转化为千分位格式,可以在数字前面加上符号 toDecimalMark(num: number, mark = ""): string

num: 操作数 mark: 操作符 (如:¥、$)

toDecimalMark(12345674654.123,'¥') // => "¥12,345,674,654.123"

epsEqDecimal

判断小数是否相等 epsEqDecimal(x: number, y: number): boolean

x: 操作数(小数) y: 操作数(小数)

epsEqDecimal(1.2, 1.2) // true

px2vw

单位转换 px 转 vw: px2vw(v: number, useUnit = true): string

v px数值 useUnit: 是否添加 vw 单位

px2vw(33) // 4.4vw

vw2Px

单位转换 vw 转 px:vw2Px(v: number, useUnit = true): string

v: vw数值 useUnit: 是否添加 px 单位

vw2Px(33) // 247.5px

byte2mb

文件大小单位转换 byte 转 mb:byte2mb(num: number): string

num: kb数值

kb2mb(15960000) // 15.96M

formatPrice

格式化为金额(传入单位为分的数值) formatPrice(num: number, formatStr?: string, padZero=true): string

num:金额(分) formatStr:格式化的字符(如:¥、$)

formatPrice(2300, '$') // $23

unFormat

去掉数值(一般为单位是分的金额)后面的0:unFormat(num: number)

num:操作数

unFormat(2.10) // 2.1
unFormat(2.00) // 2

formatNum

数字格式化 formatNum(v: number, formatStr: string)

v: 操作数 formatStr:?

formatNum(123.123) // '123'

add

加( 主要用于小数 ):add(x: number, y: number): number

x: 操作数(小数) y: 操作数(小数)

add(1.1, 2.2) // 3.3

sub

减( 主要用于小数 ):sub(x: number, y: number): number

x: 操作数(小数) y: 操作数(小数)

sub(2.1, 1.1) // 1

mul

乘( 主要用于小数 ):mul(x: number, y: number): number

x: 操作数(小数) y: 操作数(小数)

mul(2.2, 1.1) // 2.42

div

除( 主要用于小数 ):div(x: number, y: number): number

x: 操作数(小数) y: 操作数(小数)

div(6.6, 3.3) // 2

toPercent

小数转为百分数:toPercent( n: number, fixed: number )

n: 数值 fixed: 保留小数位数

toPercent(0.85633, 1) // '85.6%'

formatMoney

格式化金额: 显示 整数或小数 formatMoney (price: number, symbol: string, fixed: number)

price:价格 symbol:价格符号($、¥、'') fixed:保留小数位数(0、1、2)

formatMoney(5050, '$', 1) // '+$50.5'

formatWeek

获取星期 或 周 的某一天 formatWeek ( num: number, fmtStr = 'ww', startOfZero = true)

num: 第几天 fmtStr: w 周, ww 星期 startOfZero: true 下标为 0 是 '一', false 下标为 1 是 '日'

formatWeek(2, 'w', false) // '周二'
formatWeek(2, 'w', true) // '星期三'

BaseUtils

  • isAndroid
  • isIphone
  • isIpad
  • isWx
  • isAli
  • isPhone
  • isObject
  • isFunction
  • isString
  • isBoolean
  • isPlainObject
  • isUndefined
  • isArray
  • isNull
  • isNullOrUndefined
  • isEmpty
  • deepClone
  • deepMerge

isAndroid

当前环境 是否是安卓

返回值是 Boolean

isAndroid // true: 是安卓, false: 不是安卓

isIphone

当前环境 是否是 iphone 或 ipad

返回值是 Boolean

isIphone // true: 是iphone 或 ipad, false: 不是

isIpad

当前环境 是否是 ipad

返回值是 Boolean

isIpad // true: 是 ipad, false: 不是 ipad

isWx

当前环境 是否是微信环境

返回值是 Boolean

isWx // true: 是 微信环境, false: 不是 微信环境

isAli

当前环境 是否是支付宝环境

返回值是 Boolean

isAli // true: 是 支付宝环境, false: 不是 支付宝环境

isPhone

当前环境 是否是手机端 (iPhone|iPad|iPod|iOS|Android)

返回值是 Boolean

isPhone // true: 是 手机端, false: 不是 手机端

isObject

是否是对象

返回值是 Boolean

isObject({name: 'mike'}) // true: 是 对象
isObject('nihao') // false: 不是 对象

isFunction

是否是方法

返回值是 Boolean

isFunction // true: 是 方法, false: 不是 方法

isString

是否是字符串

返回值是 Boolean

isString // true: 是 字符串, false: 不是 字符串

isNumber

是否是 Number

返回值是 Boolean

isNumber // true: 是 Number, false: 不是 Number

isBoolean

是否是 Boolean

返回值是 Boolean

isObject // true: 是 Boolean, false: 不是 Boolean

isPlainObject

是否是 字面量定义的对象

返回值是 Boolean

isPlainObject // true: 是 字面量定义的对象, false: 不是 字面量定义的对象

isUndefined

是否是 undefined

返回值是 Boolean

isUndefined // true: 是 undefined, false: 不是 undefined

isArray

是否是 数组

返回值是 Boolean

isArray // true: 是 数组, false: 不是 数组

isDate

是否是 Date

返回值是 Boolean

isDate // true: 是 Date, false: 不是 Date

isNull

是否是 null

返回值是 Boolean

isUndefined // true: 是 null, false: 不是 null

isNullOrUndefined

是否是 null 或 undefined

返回值是 Boolean

isNullOrUndefined // true: 是 null 或 undefined, false: 不是 null 或 undefined

isEmptyObj

是否为空,包括空对象,空数组,空字符串,null,undefined: isEmptyObj (obj: any)

obj: 任意对象

const nu = null, undef = undefined
isEmptyObj({}) // true
isEmptyObj([]) // true
isEmptyObj('') // true
isEmptyObj(nu) // true
isEmptyObj(undef) // true
isEmptyObj('hello') // false

deepClone

深拷贝 deepClone(obj: any): any

obj: 任意对象

const a = { foo: 0 }, b = { foo: 0, bar: 1 }, arr = [a, b], noop = () => {};
deepClone(a) // { foo: 0 };
deepClone(b) // { foo: 0, bar: 1 };
deepClone(noop) // () => {};
deepClone(arr) // [ { foo: 0 }, { foo: 0, bar: 1 } ];
deepClone(undefined) // undefined;

deepMerge

深合并:将源对象复制到目标对象 deepMerge(object: any, ...sources: any[]): any

object: 合并的目标对象 sources:源对象

let object = {name: 'hello'}, sources = ['w','o']
deepMerge( object, sources ) // { "0": "w", "1": "o", "name": "hello" }

RulesUtils

  • phoneReg
  • priceReg
  • idCardReg
  • officeCertReg
  • passportReg
  • hmCardReg
  • chineseReg
  • intReg
  • gtZeroIntReg
  • emailReg
  • telReg
  • englishReg
  • numberOrLetterReg
  • urlReg
  • hasSpaceReg
  • nameReg
  • specialCharReg
  • imageReg
  • lenLess6Reg
  • lenMore20Reg
  • allNumReg
  • allLetterReg
  • allSpecialCharsReg
  • hasOtherCharReg
  • repeatedMore3Reg

phoneReg

校验 手机号 正则表达式

phoneReg.test('13155695875') // true
phoneReg.test('123456789') // fasle

phoneRule

校验 手机号 正则表达式对象

phoneRule.pattern.test('123456789') // fasle
phoneRule.message // '请输入正确的手机号码'

priceReg

校验 合法价格 正则表达式

最多保留两们小数

priceReg.test('2.33') // true
priceReg.test('2.3333') // fasle

priceRule

校验 合法价格 正则表达式对象

priceRule.pattern.test('2.3333') // fasle
priceRule.message // '请输入最多两位小数的金额'

idCardReg

校验 身份证号 正则表达式

idCardReg.test('360622198502025523') // true
idCardReg.test('123456789') // fasle

idCardRule

校验 身份证号 正则表达式对象

idCardRule.pattern.test('123456789') // fasle
idCardRule.message // '身份证格式不正确'

officeCertReg

校验 军官证 正则表达式

officeCertReg.test('政字第00111206号') // true
officeCertReg.test('123456789') // fasle

officeCertRule

校验 军官证 正则表达式对象

officeCertRule.pattern.test('123456789') // fasle
officeCertRule.message // '军官证格式不正确'

passportReg

校验 护照 正则表达式

passportReg.test('H280013(6)') // true
passportReg.test('123456789') // fasle

passportReg

校验 护照 正则表达式对象

passportReg.pattern.test('123456789') // fasle
passportReg.message // '护照格式不正确'

hmCardReg

校验 港澳通行证 正则表达式

hmCardReg.test('G07643214') // true
hmCardReg.test('123456789') // fasle

hmCardRule

校验 港澳通行证 正则表达式对象

hmCardRule.pattern.test('123456789') // fasle
hmCardRule.message // '港澳通行证格式不正确'

chineseReg

校验 中文字符 正则表达式

chineseReg.test('你好') // true
chineseReg.test('123456789') // fasle

chineseRule

校验 中文字符 正则表达式对象

chineseRule.pattern.test('123456789') // fasle
chineseRule.message // '请输入中文字符'

within0IntReg

校验 大于等于0的正整数 正则表达式

within0IntReg.test('0') // true
within0IntReg.test('-2') // fasle

within0IntRule

校验 大于等于0的正整数 正则表达式对象

within0IntRule.pattern.test('-2') // fasle
within0IntRule.message // '请输入大于等于0的正整数'

more0IntReg

校验 大于0的正整数 正则表达式

more0IntReg.test('12') // true
more0IntReg.test('0') // fasle

more0IntRule

校验 大于0的正整数 正则表达式对象

more0IntRule.pattern.test('0') // fasle
more0IntRule.message // '请输入大于0的整数'

emailReg

校验 邮箱 正则表达式

emailReg.test('[email protected]') // true
emailReg.test('123456789') // fasle

emailRule

校验 邮箱 正则表达式对象

emailRule.pattern.test('13155695875') // false
emailRule.message // '邮箱格式不正确'

telReg

校验 座机号 正则表达式

telReg.test('015-1454514') // true
telReg.test('123456789') // fasle

telRule

校验 座机号 正则表达式对象

telRule.pattern.test('13155695875') // fasle
telRule.message // '座机号格式不正确'

englishReg

校验 字母 正则表达式

englishReg.test('abcdefg') // true
englishReg.test('123456789') // fasle

englishRule

校验 字母 正则表达式对象

englishRule.pattern.test('13155695875') // fasle
englishRule.message // '请输入英文字符'

numberOrLetterReg

校验 数字或字母 正则表达式

numberOrLetterReg.test('123abc') // true
numberOrLetterReg.test('你哈') // fasle

numberOrLetterRule

校验 数字或字母 正则表达式对象

numberOrLetterRule.pattern.test('你哈') // fasle
numberOrLetterRule.message // '请输入数字或字母'

urlReg

校验 url地址 正则表达式对象

urlReg.test('https://hello.com') // fasle
urlReg.test('你哈') // fasle

urlRule

校验 url地址 正则表达式

urlRule.pattern.test('你哈') // true
urlRule.message // '请输入以 http: 或 https: 开头的链接地址'

hasSpaceReg

校验 字符串中是否有空格 正则表达式

hasSpaceReg.test('1 2') // true
hasSpaceReg.test('你哈') // fasle

hasSpaceRule

校验 字符串中是否有空格 正则表达式对象

hasSpaceRule.pattern.test('你哈') // fasle
hasSpaceRule.message // '不能含有空格'

nameReg

校验 姓名 正则表达式

nameReg.test('李好好') // true
nameReg.test('123') // fasle

nameRule

校验 姓名 正则表达式对象

nameRule.pattern.test('123') // fasle
nameRule.message // '请输入正确姓名'

specialCharReg

校验 数字或字母 正则表达式

specialCharReg.test('!@#$%^&') // true
specialCharReg.test('你哈') // fasle

specialCharRule

校验 数字或字母 正则表达式对象

specialCharRule.pattern.test('!@#$%^&') // true
specialCharRule.message // '不能包含特殊字符'

imageReg

校验 数字或字母 正则表达式

imageReg.test('test.jpg') // true
imageReg.test('你哈') // fasle

imageRule

校验 数字或字母 正则表达式对象

imageRule.pattern.test('你哈') // fasle
imageRule.message // '不是图片文件'

lenLess6Reg

校验 长度小于6 正则表达式(关于弱密码)

lenLess6Reg.test('123') // true
lenLess6Reg.test('123456') // fasle

lenLess6Rule

校验 长度小于6 正则表达式对象(关于弱密码)

lenLess6Rule.pattern.test('123') // true
lenLess6Rule.message // '密码长度为6-20个字符'

lenMore20Reg

校验 长度大于20 正则表达式(关于弱密码)

lenMore20Reg.test('1234567890abcdefghijklmn') // true
lenMore20Reg.test('123456') // fasle

lenMore20Rule

校验 长度大于20 正则表达式对象(关于弱密码)

lenMore20Rule.pattern.test('1234567890abcdefghijklmn') // true
lenMore20Rule.message // '密码长度为6-20个字符'

allNumReg

校验 只有数字 正则表达式(关于弱密码)

allNumReg.test('123456') // true
allNumReg.test('123456aa') // fasle

allNumRule

校验 只有数字 正则表达式对象(关于弱密码)

allNumRule.pattern.test('123456') // true
allNumRule.message // '密码由数字、特殊字符(! # $ % ^ & * @)、字母中的至少两种组成'

allLetterReg

校验 只有字母 正则表达式(关于弱密码)

allLetterReg.test('abcdefg') // true
allLetterReg.test('123456aaa') // fasle

allLetterRule

校验 只有字母 正则表达式对象(关于弱密码)

allLetterRule.pattern.test('abcdefg') // true
allLetterRule.message // '密码由数字、特殊字符(! # $ % ^ & * @)、字母中的至少两种组成'

allSpecialCharsReg

校验 只有特殊字符 正则表达式(关于弱密码)

allSpecialCharsReg.test('#$%^*@') // true
allSpecialCharsReg.test('123456%%$') // fasle

allSpecialCharRule

校验 只有特殊字符 正则表达式对象(关于弱密码)

allSpecialCharRule.pattern.test('#$%^*@') // true
allSpecialCharRule.message // '密码由数字、特殊字符(! # $ % ^ & * @)、字母中的至少两种组成'

hasOtherCharReg

校验 包含规定特殊字符以外的字符 正则表达式(关于弱密码)

hasOtherCharReg.test('123++@@') // true
hasOtherCharReg.test('123456@@') // fasle

hasOtherCharRule

校验 包含规定特殊字符以外的字符 正则表达式对象(关于弱密码)

hasOtherCharRule.pattern.test('123++@@') // true
hasOtherCharRule.message // '密码由数字、特殊字符(! # $ % ^ & * @)、字母中的至少两种组成'

repeatedMore3Reg

校验 有连续3位重复的字符 正则表达式(关于弱密码)

repeatedMore3Reg.test('12311111') // true
repeatedMore3Reg.test('123456') // fasle

repeatedMore3Rule

校验 有连续3位重复的字符 正则表达式对象(关于弱密码)

repeatedMore3Rule.pattern.test('12311111') // true
repeatedMore3Rule.message // '密码不能有3位连续或重复的字符'

StringUtils

  • numberMask
  • getFileSuffix
  • delWhitespace
  • nameMask
  • randomId
  • idCardAndPhoneMask
  • getInfoByIdCard

numberMask

给指定位置添加 * 遮蔽 字符串: numberMask(str: string, startIndex = 0, endIndex = 0, _mask = "*"): string

str:字符串 startIndex: 起始索引 endIndex: 结束索引 _mask: 遮蔽字符

utilscore.mask('12398765432',3,7) // => "123****5432"

getFileSuffix

获取文件后缀: getFileSuffix(fileName: string): string

fileName: 文件名

getFileSuffix('1.jpg') // .jpg

delWhitespace

去除字符串中的空格: delWhitespace(input: string): string

input: 字符串

deleteWhitespace('我是 测试 的 字符串  '); // '我是测试的字符串'
deleteWhitespace(''); //''

randomId

创建指定长度的ID,可添加前缀: randomId(length = 6, prefix = ""): string

length: id的长度,不包含前缀长度 | 默认是 6 prefix 前缀 | 默认为空

randomId() // 05bbfd

idCardAndPhoneMask

证件号脱敏(身份证/军官证/护照/港澳身份证/手机号)idCardAndPhoneMask(val: string): string

val: 证件号 | string ISOString: 是否使用 ISO 标准返回 Date 对象的字符串格式 | Boolean

idCardAndPhoneMask('110101199003074813') // 110********4813
idCardAndPhoneMask('南字第3044444号') // 南字第****444号
idCardAndPhoneMask('G07643214') //  G0***3214
idCardAndPhoneMask('H280013(6)') // H2****3(6)
idCardAndPhoneMask('13028829998') // 130****9998

nameMask

名字脱敏,脱敏倒数第二个字或字母: nameMask(name: string): string

name: 名称

nameMask('张三') // 张*
nameMask('张小三') // 张*三
nameMask('张标准三') // 张*三

getInfoByIdCard

根据身份证获取身份信息(年龄、性别、生日): getInfoByIdCard( idCard: String ): {age: number, gender: number, birthday: string}

idCard: 身份证号码

return: {age: number, gender: number, birthday: string}

getInfoByIdCard('360622199606296621') --> { "age": 24, "birthYear": "1996", "gender": 1 }

URLUtils

  • url
  • getUrlParam
  • resolve
  • urlToList
  • removeParam
  • addParam
  • updateParam
  • obj2pms
  • buildUrl
  • push
  • replace
  • go
  • doWxAuth

getUrlParam

获取url中查询参数的值 getUrlParam(key?: string, path?: string): string | Record<string, string>

key:获取对应key的值 | 默认获取所有 key 值 path:url地址 | 默认当前地址

getUrlParam('name', 'http://hh.com?name=aaa') // 'aaa'

resolve

url 拼接 resolve(href: string, path: string): string

href: url地址 path: 路径

 resolve('http://foo.com/a/', 'b/c') => http://foo.com/a/b/c

urlToList

url 转为 数组 urlToList(url: string): string[]

url: url地址

urlToList('http://foo.com/a/') => ["/http:", "/http:/foo.com", "/http:/foo.com/a"]

removeParam

删除 查询参数 (hash路径不适用) removeParam(keys: string[], path?: string): string

keys: 要删除的 key 的集合 path: 地址 | 默认为当前地址

removeParam(['name'],'http://foo.com/a?name=mike') // 'http://foo.com/a'

addParam

添加 查询参数(hash路径不适用): addParam(params: Record<string, any>, path?: string): string

params 要添加的键值对 path: 地址 | 默认为当前地址

addParam({name: 'mike'}, 'http://foo.com/a') // 'http://foo.com/a?name=mike'

updateParam

更新 查询参数(hash路径不适用)

params 要添加的键值对 path: 地址 | 默认为当前地址

updateParam({name: 'mike'}, 'http://foo.com/a?name=july') // 'http://foo.com/a?name=mike'

obj2pms

对象转URL参数 obj2pms(obj: any)

obj: JSON对象

obj2pms({a:1, b:2}) => 'a=1&b=2'

buildUrl

构建跳转链接 buildUrl(path: string, params: any): string

path: 路径 params: JSON对象

buildUrl('/login', {from: 'home'}) => '/login?from=home'

push

改变 location.href: push(options: RouterOption | string)

options: {path: '', query: {}} | url: string

push('/login') 或 push('/login',{name: 'a'}) // window.location.href = '/login?name=a'

replace

改变 location.replace: replace(options: RouterOption | string)

options: {path: '', query: {}} | url: string

replace('/login') 或 replace('/login',{name: 'a'})

go

浏览器地址回退 : go(num: number)

num:number

go(-1) // 浏览器地址回退 1步

doWxAuth

微信网页授权: doWxAuth(appid: string)

appId:微信appId

 if(!sessionStorage.getItem('code')) doWxAuth('xxxx')