zhaobinglong / myBlog

https://zhaobinglong.github.io/myBlog/
MIT License
7 stars 0 forks source link

npm应用 #132

Open zhaobinglong opened 3 years ago

zhaobinglong commented 3 years ago

配置npm私有仓库地址

// 可以在npmrc中配置npm源
registry=https://npm-registry.megvii-inc.com
zhaobinglong commented 3 years ago

随机真实用户自拍头像

随机公司名字

随机真实存在的地址

zhaobinglong commented 3 years ago

Excel处理

link:https://github.com/SheetJS/js-xlsx

导入两个npm包。需安装

import FileSaver from 'file-saver'
import XLSX from 'xlsx'

导出函数(给table一个id或者class)

            exportExcel() {
                 /* generate workbook object from table */
                 var wb = XLSX.utils.table_to_book(document.querySelector(".my-table"))
                 /* get binary string as output */
                 var wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' })
                 try {
                     FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), 'sheetjs.xlsx')
                 } catch (e) { 
                    if (typeof console !== 'undefined') {
                       console.log(e, wbout)  
                    }
                }
                 return wbout
            },  

修复导出的excel中身份证号码异常

  exportExcel() {
       /* 添加 { raw: true } */
       var wb = XLSX.utils.table_to_book(document.querySelector("#my-table"), { raw: true })
  }, 

参考:

https://blog.csdn.net/wjf1997/article/details/90580790

zhaobinglong commented 3 years ago

随机中文名字

https://github.com/XadillaX/chinese-random-name