Skip to content

Commit f7ff827

Browse files
committed
feat(util): add vue runtime
1 parent 109995a commit f7ff827

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/util/runtime.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import Vue from 'vue';
2+
3+
interface Runtime {
4+
vm?: Vue;
5+
}
6+
7+
const runtime: Runtime = {};
8+
9+
export function getRuntimeVM(): Vue {
10+
if (runtime.vm) return runtime.vm;
11+
throw new ReferenceError('[vue-hooks] Not found vue instance.');
12+
}
13+
14+
export function setRuntimeVM(this: Vue, vm?: Vue) {
15+
runtime.vm = this || vm;
16+
}

0 commit comments

Comments
 (0)