diff --git a/src/main.js b/src/main.js index ab57ef6f..deacb752 100755 --- a/src/main.js +++ b/src/main.js @@ -29,11 +29,12 @@ import '@/mock/index.js' // vuex import store from '@/store/index.js' -import d2Admin from '@/plugin/d2Admin' +// log简化 +import pluginLog from '@/plugin/log' Vue.use(ElementUI) -Vue.use(d2Admin) +Vue.use(pluginLog) Vue.config.productionTip = false diff --git a/src/pages/core/login/index.vue b/src/pages/core/login/index.vue index 00b73850..01d268b5 100644 --- a/src/pages/core/login/index.vue +++ b/src/pages/core/login/index.vue @@ -75,9 +75,7 @@ export default { } }) .then (res => { - console.group('登录') - console.log(res) - console.groupEnd() + this.$log('登录结果', res) }) } else { return false diff --git a/src/plugin/d2Admin/index.js b/src/plugin/d2Admin/index.js deleted file mode 100644 index 9e267962..00000000 --- a/src/plugin/d2Admin/index.js +++ /dev/null @@ -1,9 +0,0 @@ -export default { - install (Vue, options) { - Vue.mixin({ - created () { - console.log('hahaha') - } - }) - } -} diff --git a/src/plugin/log/index.js b/src/plugin/log/index.js new file mode 100644 index 00000000..327a1322 --- /dev/null +++ b/src/plugin/log/index.js @@ -0,0 +1,18 @@ +export default { + install (Vue, options) { + // 打印log + // 如果只有一个参数 就只简单打印第一个参数 + // 如果有大于一个参数 第一个参数会当做是分组的名称 + Vue.prototype.$log = (arg1 = 'log', ...logs) => { + if (logs.length === 0) { + console.log(arg1) + } else { + console.group(arg1) + logs.forEach(e => { + console.log(e) + }) + console.groupEnd() + } + } + } +}