| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- import Vue from 'vue'
- let log = function (title, object) {
- let currentUrl = ""
- // #ifdef H5
- currentUrl = window.location.href
- // #endif
- console.log("┏━━━━━ 打印开始 Url: " + currentUrl + " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
- if (!object) {
- object = title
- } else {
- //创建新数组,存放数据及样式
- let arr1 = [''];
- //给每一个黑字设置样式
- arr1[0] += '%c' + title;
- //用随机函数生成三位数代表rgb颜色
- let random1 = randomFunc();
- arr1[1] = 'color:#fff;font-size:15px;background-color:#' + random1;
- console.log.apply(console, arr1)
- }
- let jsonStr = JSON.stringify(object, null, 2);
- //创建新数组,存放数据及样式
- let arr = [''];
- //给每一个黑字设置样式
- arr[0] += '%c' + jsonStr;
- //用随机函数生成三位数代表rgb颜色
- let random = randomFunc();
- arr[1] = 'color:#fff;font-size:15px;background-color:#' + random;
- //arr[1]='font-size:15px;color:#'+random;
- console.log.apply(console, arr)
- console.log("┗━━━━━ 打印结束 Url: " + currentUrl + " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
- }
- let randomFunc = function () {
- let random = Math.random().toFixed(3) * 1000;
- if (random <= 100) {
- return randomFunc();
- } else {
- return random;
- }
- }
- // 添加到 Vue原型链
- // 临时调试方法
- Vue.prototype.$log = log
- // #ifdef H5
- window.log = log
- // #endif
|