Skip to content

Commit 0f11f1e

Browse files
committed
feat: support @vue:mounted & @vnode-mounted in Vue 3
1 parent b4f534e commit 0f11f1e

File tree

10 files changed

+206
-171
lines changed

10 files changed

+206
-171
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ app.use(YourComponent, {
4040
},
4141

4242
// Global Hook
43-
'@vnodeMounted': function () {
43+
'@vue:mounted': function () {
4444
console.log('Global Mounted')
4545
},
4646

@@ -109,7 +109,7 @@ Entangled in global/local/default parameters, which one to choose? It should be
109109
- Support triggering either global listener or local listener
110110
- Support current instance (`this`) access
111111
- Support global **Hooks** (internal API)
112-
- Such as `@vnodeMounted` in Vue 3, see https://github.com/vuejs/core/issues/4457
112+
- Such as `@vue:mounted`/`@vnode-mounted`/`@vnodeMounted`/`onVnodeMounted` in Vue 3, see https://github.com/vuejs/core/issues/4457
113113
- Such as `@hook:mounted` in Vue 2, see https://github.com/vuejs/vue/issues/10312
114114
- Support current instance (`this`) access
115115
- Support global **Slots** & **Scoped Slots**

__tests__/conclude.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from 'vitest'
2-
import conclude from '../src/conclude'
2+
import { conclude } from 'vue-global-config'
33

44
describe('conclude', () => {
55
describe('非plain object', () => {

demo/vue2.6/YourComponent.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- eslint-disable vue/no-v-for-template-key-on-child -->
22
<script>
3-
import { conclude, getLocalListeners, listenGlobalHooks, resolveConfig } from '../../src'
3+
import { conclude, getLocalListeners, listenGlobalHooks, resolveConfig } from 'vue-global-config'
44
55
const globalProps = {}
66
const globalAttrs = {}

demo/vue2.7/YourComponent/Component.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- eslint-disable vue/no-v-for-template-key-on-child -->
22
<script lang="ts" setup>
33
import { computed, useAttrs } from 'vue'
4-
import { conclude, getLocalListeners, listenGlobalHooks } from '../../../src'
4+
import { conclude, getLocalListeners, listenGlobalHooks } from 'vue-global-config'
55
import { globalAttrs, globalHooks, globalListeners, globalProps, globalSlots } from './index'
66
77
const props = defineProps(['title'])

demo/vue2.7/YourComponent/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Plugin, install } from 'vue-demi'
2-
import { resolveConfig } from '../../../src'
2+
import { resolveConfig } from 'vue-global-config'
33
import Component from './Component.vue'
44

55
type SFCWithInstall<T> = T & Plugin & { install: typeof install }

demo/vue3/YourComponent/Component.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts" setup>
22
import { computed, useAttrs, useSlots } from 'vue'
3-
import { conclude } from '../../../src'
3+
import { conclude } from 'vue-global-config'
44
import { globalAttrs, globalHooks, globalListeners, globalProps, globalSlots } from './index'
55
66
const props = defineProps(['title'])

demo/vue3/YourComponent/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Plugin, install } from 'vue-demi'
2-
import { resolveConfig } from '../../../src'
2+
import { resolveConfig } from 'vue-global-config'
33
import Component from './Component.vue'
44

55
type SFCWithInstall<T> = T & Plugin & { install: typeof install }

demo/vue3/index.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,24 @@ const app = createApp(App)
4141
console.log('Global LeftCheckChange')
4242
},
4343

44+
// Global Hook
45+
'@vue:mounted': function () {
46+
console.log('Global Mounted (from @vue:mounted)')
47+
},
48+
49+
// Global Hook
50+
'@vnode-mounted': function () {
51+
console.log('Global Mounted (from @vnode-mounted)')
52+
},
53+
4454
// Global Hook
4555
'@vnodeMounted': function () {
46-
console.log('Global Mounted')
56+
console.log('Global Mounted (from @vnodeMounted)')
57+
},
58+
59+
// Global Hook
60+
'onVnodeMounted': function () {
61+
console.log('Global Mounted (from onVnodeMounted)')
4762
},
4863

4964
// Global Slot

0 commit comments

Comments
 (0)