Files
d2-admin-start-kit/src/plugin/log/index.js
T
liyang d07d15ed8c D2Admin 1.7
Former-commit-id: 3010ce31114fdc121006451c72f9e18306239fd2
2019-05-07 09:26:18 +08:00

26 lines
659 B
JavaScript

import store from '@/store'
import util from '@/libs/util'
export default {
install (Vue, options) {
// 快速打印 log
Vue.prototype.$log = {
...util.log,
push (data) {
if (typeof data === 'string') {
// 如果传递来的数据是字符串
// 赋值给 message 字段
// 为了方便使用
// eg: this.$log.push('foo text')
store.dispatch('d2admin/log/push', {
message: data
})
} else if (typeof data === 'object') {
// 如果传递来的数据是对象
store.dispatch('d2admin/log/push', data)
}
}
}
}
}