caroundsky / QA

0 stars 0 forks source link

Js零散点 #6

Open caroundsky opened 1 year ago

caroundsky commented 1 year ago

填充数组

// 使用array.from
const length = 3
const init = 0
const result = Array.from({ length }, () => init) // => [0, 0, 0]

// 使用fill
const length = 3
const resultA = Array.from({ length }, () => ({}))
const resultB = Array(length).fill({})

// 填充的内容为对象
const length = 3
const resultA = Array.from({ length }, () => ({}))
const resultB = Array(length).fill({})

换行正则

'1,3 545,65 656,45'.split(/[,, \n\t]/) 

-> ['1', '3', '545', '65', '656', '45']

导出用到await blob.text() 出现t.text undefined 问题

用try catch绕过该方法,并提示建议您的浏览器版本太低,可能会导致导出失败,建议升级您的浏览器版本

火狐浏览器兼容e.path

生成后缀名为"."的配置文件

windows7/8输入 ren 1.txt .gitignore修改成功 windows10输入 mv 1.txt .gitignore修改成功