当前位置: 首页 > news >正文

黄冈建设局网站湖南产品网络营销推荐咨询

黄冈建设局网站,湖南产品网络营销推荐咨询,全屋定制十大名牌排行榜,启迪网站建设console.log封装 在控制台中打印带有颜色和格式的日志信息。 /*** 检查给定的对象是否为数组*/ const isArray function (obj: any): boolean {return Object.prototype.toString.call(obj) [object Array] }/*** Logger 构造函数*/ Logger () > {}/*** 根据日志类型返回…

console.log封装

在控制台中打印带有颜色和格式的日志信息。

/*** 检查给定的对象是否为数组*/
const isArray = function (obj: any): boolean {return Object.prototype.toString.call(obj) === '[object Array]'
}/*** Logger 构造函数*/
Logger = () => {}/*** 根据日志类型返回对应的颜色*/
Logger.typeColor = function (type: string) {let color = ''switch (type) {case 'primary':color = '#2d8cf0'breakcase 'success':color = '#19be6b'breakcase 'info':color = '#909399'breakcase 'warn':color = '#ff9900'breakcase 'error':color = '#f03f14'breakdefault:color = '#35495E'break}return color
}/*** 打印日志信息,可选择是否带有背景色*/
Logger.print = function (type = 'default', text: any, back = false) {if (typeof text === 'object') {// 如果是對象則調用打印對象方式isArray(text) ? console.table(text) : console.dir(text)return}if (back) {// 如果是打印帶背景圖的console.log(`%c ${text} `,`background:${Logger.typeColor(type)}; padding: 2px; border-radius: 4px; color: #fff;`)} else {console.log(`%c ${text} `,`border: 1px solid ${Logger.typeColor(type)};padding: 2px; border-radius: 4px;color: ${Logger.typeColor(type)};`)}
}/*** 打印带有背景色的日志信息*/
Logger.printBack = function (type = 'primary', text) {this.print(type, text, true)
}/*** 打印格式化的日志信息,可选择是否带有背景色*/
Logger.pretty = function (type = 'primary', title, text) {if (typeof text === 'object') {console.group('Console Group', title)console.log(`%c ${title}`,`background:${Logger.typeColor(type)};border:1px solid ${Logger.typeColor(type)};padding: 1px; border-radius: 4px 0 0 4px; color: #fff;`)isArray(text) ? console.table(text) : console.dir(text)console.groupEnd()return}console.log(`%c ${title} %c ${text} %c`,`background:${Logger.typeColor(type)};border:1px solid ${Logger.typeColor(type)};padding: 1px; border-radius: 4px 0 0 4px; color: #fff;`,`border:1px solid ${Logger.typeColor(type)};padding: 1px; border-radius: 0 4px 4px 0; color: ${Logger.typeColor(type)};`,'background:transparent')
}/*** 使用 primary 类型打印格式化的日志信息*/
Logger.prettyPrimary = function (title, ...text) {text.forEach((t) => this.pretty('primary', title, t))
}/*** 使用 success 类型打印格式化的日志信息*/
Logger.prettySuccess = function (title, ...text) {text.forEach((t) => this.pretty('success', title, t))
}/*** 使用 warn 类型打印格式化的日志信息*/
Logger.prettyWarn = function (title, ...text) {text.forEach((t) => this.pretty('warn', title, t))
}/*** 使用 error 类型打印格式化的日志信息*/
Logger.prettyError = function (title, ...text) {text.forEach((t) => this.pretty('error', title, t))
}/*** 使用 info 类型打印格式化的日志信息*/
Logger.prettyInfo = function (title, ...text) {text.forEach((t) => this.pretty('info', title, t))
}export default Logger
http://www.yayakq.cn/news/101562/

相关文章:

  • 模版网站可以做seo吗深圳市响应式网站建设
  • 天津网站的建设苏州企业建设网站
  • 中国营销传播网手机版入口江西省seo
  • 做的网站必须备案网站打开慢的解决方法
  • 中小企业建设网站应注意wordpress优雅的暂停
  • 大唐网站设计软件开发公司在哪里
  • 河北省城乡建设培训网官方网站wordpress相册设置
  • 双阳区住房和城乡建设局网站定制app网站
  • 做静态页面的网站上海百度优化
  • 盐城网站优化公司想做电商网站运营要怎么做
  • 有哪些平面设计网站枣庄市住房和建设局网站
  • 酒店网站建设流程今标 网站建设
  • 广州网站制作知名 乐云践新国外社交网站设计欣赏
  • dw做的网站怎么在vs智慧团建手机版入口
  • 微信小程序网站建设方案dedecms网站怎么搬家
  • 网站违法和做网站得有关系常用的网络推广方式有哪些
  • 网站手机访问 动易容桂网站智能推广新闻
  • 自适应网站欣赏联赛网站建设不足
  • 商丘 网站建设全网营销推广是什么
  • 网站建设成品伪静态规则变动对网站的影响
  • 网站统计网站建设与制作就业前景
  • 网站更换ico文件位置wordpress使用七牛图床
  • 成都网站建设企业seo建站教学
  • 网站后台html5模板二手房
  • 网站建设方案书个人做产品包装的3d网站
  • 十大小说网站排名地推app接任务平台
  • 山东省建设工程招投标网站响应式网站设计教程
  • 2015做那些网站致富上海网站建设网页制
  • project 网站开发计划服装页面设计的网站
  • 霞山网站建设公司设计师兼职平台