Skip to content

Commit 44f87a0

Browse files
committed
fix: hook装饰器未传递参数
1 parent e5f4c8c commit 44f87a0

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

example/main.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import '@abraham/reflection'
2-
import { Component, Mut, VueComponent } from 'vue3-oop'
2+
import { Component, Hook, Mut, VueComponent } from 'vue3-oop'
33
import { createApp } from 'vue'
44
import 'ant-design-vue/dist/antd.css'
55
import { ConfigProvider, Layout, Menu } from 'ant-design-vue'
@@ -13,12 +13,20 @@ import { setup } from './setup'
1313
class App extends VueComponent {
1414
@Mut() collapsed = false
1515

16+
@Hook('ErrorCaptured')
17+
error(...args: any[]) {
18+
console.log(args)
19+
}
20+
1621
render() {
1722
return (
1823
<ConfigProvider locale={zhCN}>
1924
<Layout style={{ minHeight: '100vh' }}>
2025
<Layout.Sider v-model:collapsed={this.collapsed} collapsible>
2126
<h2
27+
onClick={() => {
28+
throw new Error('hahaha')
29+
}}
2230
style={{ color: '#fff', textAlign: 'center', lineHeight: '40px' }}
2331
>
2432
VUE 示例

src/decorators/hook.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function handler(targetThis: any) {
9191
break
9292
}
9393
doneLife[option] = true
94-
vueFn(() => targetThis[item.key]())
94+
vueFn((...args: any[]) => targetThis[item.key](...args))
9595
}
9696
}
9797
}

0 commit comments

Comments
 (0)