当前位置: 首页 > 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/861105/

相关文章:

  • 大连网站制作美工杭州营销策划推广公司
  • 网站引入优酷视频服装设计公司属于什么行业类型
  • 如何制作app网站同心县建设局网站
  • 山东住房城乡建设厅网站朔州如何做百度的网站
  • 外贸网站品牌官网建设制作书签图片
  • 共享ip服务器做网站建网站云空间
  • 教育行业网站建设中国石油第一建设公司官网
  • 学好网页设计与网站建设的意义网站建设免费网站
  • 手机上打开html的软件潮州网站推广优化
  • 广东微信网站制作费用网页设计实训内容及过程
  • 赣州网站建设策划提供网站建设哪家好
  • 安阳那里可以制作网站微信小程序组件库
  • 做网站不实名认证可以吗2021中国建筑企业500强排名
  • 做物流网站的多少钱个人网站开发公司
  • 做qq图片的网站吗商务网站建设过程
  • 山西中宇建设集团网站大同市建设工程质量监督站网站
  • 中卫市建设局网站济南建站免费模板
  • 宁波电子商务网站建设外国排版网站
  • 网站基础知识域名5个点网站的功能定位和建设运营规划
  • 网站是怎么建成的wordpress 登录页面
  • 网站建设及政务工作自查帮助企业做网站的销售
  • 免费的报告网站黄埔五屏网站建设
  • 计算机网站开发职业定位桂林北站到象鼻山多远
  • 网站开发者选项关于做教育新闻的网站
  • 旅游网站建站目的wordpress收费版验证方式
  • wps哪个工具做网站四川成都网站优化
  • 第三方网站流量统计wordpress阿里云数据库
  • 网站模板内容怎么添加图片眉县住房和城乡建设局网站
  • 网站怎么做黑链接做泵阀到哪个网站好
  • 温州外贸网站推广手机qq查看网站源码