Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周远喜
Admin
Commits
a6b07f75
Commit
a6b07f75
authored
Mar 22, 2020
by
周远喜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
插件安装,log,error捕获
parent
92334c13
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
25 deletions
+77
-25
index.vue
pages/index.vue
+8
-0
iview.js
plugins/iview.js
+69
-25
No files found.
pages/index.vue
View file @
a6b07f75
...
...
@@ -26,6 +26,7 @@
<h1>
总数:
{{
counter
}}
</h1>
<h2>
admin,user
{{
this
.
$store
.
state
.
admin
.
user
.
counter
}}
</h2>
<Button
@
click=
"increment"
>
+
</Button>
<Button
type=
"error"
@
click=
"log"
>
log
</Button>
</div>
</div>
</div>
...
...
@@ -47,6 +48,13 @@ export default {
},
methods
:
{
increment
()
{
this
.
$store
.
commit
(
'increment'
)
},
log
(){
this
.
$log
.
push
(
"这是一个错误!"
)
this
.
$log
.
capsule
(
'iView'
,
'Success'
,
this
);
if
(
process
.
env
.
NODE_ENV
===
'development'
){
alert
(
123
)
}
}
}
}
...
...
plugins/iview.js
View file @
a6b07f75
...
...
@@ -2,7 +2,10 @@ import Vue from 'vue'
import
ViewUI
from
'view-design'
import
VueI18n
from
'vue-i18n'
;
import
Languages
from
'@/i18n/locale'
;
// import VueDND from 'awe-dnd'
// 插件
import
util
from
'@/libs/util'
;
import
VueDND
from
'awe-dnd'
//拖拽排序
// import iViewPro from '@/libs/iViewPro/iview-pro.min.js';
// import '@/libs/iViewPro/iview-pro.css';
import
iViewPro
from
'../iview-pro/src/index.js'
;
...
...
@@ -16,28 +19,69 @@ Vue.component("iLink", iLink)
//注入mock
require
(
"../mock"
)
export
default
({
app
,
store
})
=>
{
Vue
.
use
(
VueI18n
)
// Vue.use(VueDND)
app
.
i18n
=
new
VueI18n
({
locale
:
'zh-CN'
,
messages
:
Languages
});
app
.
i18n
.
locale
=
"zh-CN"
Vue
.
use
(
ViewUI
,
{
// locale:'zh-CN',
i18n
:
(
key
,
value
)
=>
app
.
i18n
.
t
(
key
,
value
)
app
,
store
})
=>
{
Vue
.
use
(
VueI18n
)
Vue
.
use
(
VueDND
)
app
.
i18n
=
new
VueI18n
({
locale
:
'zh-CN'
,
messages
:
Languages
});
app
.
i18n
.
locale
=
"zh-CN"
Vue
.
use
(
ViewUI
,
{
// locale:'zh-CN',
i18n
:
(
key
,
value
)
=>
app
.
i18n
.
t
(
key
,
value
)
})
Vue
.
use
(
iViewPro
);
Vue
.
prototype
.
$log
=
{
...
util
.
log
,
push
(
data
)
{
if
(
typeof
data
===
'string'
)
{
// 如果传递来的数据是字符串
// 赋值给 message 字段
// 为了方便使用
// eg: this.$log.push('foo text')
store
.
dispatch
(
'admin/log/push'
,
{
message
:
data
});
}
else
if
(
typeof
data
===
'object'
)
{
// 如果传递来的数据是对象
store
.
dispatch
(
'admin/log/push'
,
data
);
}
}
}
Vue
.
config
.
errorHandler
=
function
(
error
,
instance
,
info
)
{
Vue
.
nextTick
(()
=>
{
// store 追加 log
store
.
dispatch
(
'admin/log/push'
,
{
message
:
`
${
info
}
:
${
error
.
message
}
`
,
type
:
'error'
,
meta
:
{
error
// instance
}
});
// 只在开发模式下打印 log
if
(
process
.
env
.
NODE_ENV
===
'development'
)
{
util
.
log
.
capsule
(
'iView Admin'
,
'ErrorHandler'
,
'error'
);
util
.
log
.
error
(
'>>>>>> 错误信息 >>>>>>'
);
console
.
log
(
info
);
util
.
log
.
error
(
'>>>>>> Vue 实例 >>>>>>'
);
console
.
log
(
instance
);
util
.
log
.
error
(
'>>>>>> Error >>>>>>'
);
console
.
log
(
error
)
}
})
Vue
.
use
(
iViewPro
);
// Vue.directive('paste', {
// bind(el, binding, vnode) {
// el.addEventListener('paste', function (event) { //这里直接监听元素的粘贴事件
// binding.value(event)
// })
// }
// })
// console.warn("this:",app.i18n.locale,app)
}
\ No newline at end of file
}
// Vue.directive('paste', {
// bind(el, binding, vnode) {
// el.addEventListener('paste', function (event) { //这里直接监听元素的粘贴事件
// binding.value(event)
// })
// }
// })
// console.warn("this:",app.i18n.locale,app)
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment