mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-06-01 13:19:18 +08:00
feat(vue-runtime-help): app不存在时抛异常,保证app一定存在,避免多余的可选链
This commit is contained in:
parent
e7e9197ae3
commit
fd7e737e8c
@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "1.1.1",
|
||||
"version": "1.1.2",
|
||||
"name": "@tmagic/vue-runtime-help",
|
||||
"type": "module",
|
||||
"sideEffects": false,
|
||||
|
@ -65,13 +65,17 @@ export const registerNodeHooks = (node?: TMagicNode, methods: Methods = {}) => {
|
||||
};
|
||||
|
||||
export const useApp = <T extends TMagicApp = TMagicApp>({
|
||||
methods = {},
|
||||
methods,
|
||||
config,
|
||||
iteratorContainerId,
|
||||
iteratorIndex,
|
||||
}: UseAppOptions) => {
|
||||
const app = inject<T>('app');
|
||||
|
||||
if (!app) {
|
||||
throw new Error(`component ${config.type}: app is not injected`);
|
||||
}
|
||||
|
||||
const node = useNode(
|
||||
{
|
||||
config,
|
||||
@ -81,7 +85,7 @@ export const useApp = <T extends TMagicApp = TMagicApp>({
|
||||
app,
|
||||
);
|
||||
|
||||
if (node) {
|
||||
if (node && methods) {
|
||||
registerNodeHooks(node, methods);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user