Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defineExpose无法在createApp.mount实例中使用 #4660

Closed
lishichao1002 opened this issue Sep 23, 2021 · 1 comment
Closed

defineExpose无法在createApp.mount实例中使用 #4660

lishichao1002 opened this issue Sep 23, 2021 · 1 comment

Comments

@lishichao1002
Copy link

Version

3.2.6

Reproduction link

Steps to reproduce

<script lang="tsx" setup>
import { Goods } from '@/api/merchant-v2';
import { reactive } from 'vue';
const state = reactive<{
    visible: Boolean;
    goods: Goods[];
}>({
    visible: false,
    goods: [],
});

defineExpose({
    open(args: { goods: Goods[] }) {
        state.visible = true;
        state.goods = args.goods;
    },
    a: 1,
    b: 2,
    log: console.log,
});
</script>
import { createApp } from 'vue';
import LiveRecordGoods from './live-record-goods.vue';

/**
 * 试试动态运行时创建实例,不用直接模板创建实例
 */
export function openRecordGoods(args: { goods: Goods[] }) {
    const app = createApp(LiveRecordGoods);
    const parent = document.createElement('div');
    const instance = app.mount(parent);
    console.log(instance);
    // 获取不到实例的方法
    (instance as any).open(args);
    document.body.appendChild(parent);
}

image
image

What is expected?

能够正常获取到export的方法

What is actually happening?

获取不到导出的方法

@LinusBorg
Copy link
Member

LinusBorg commented Sep 23, 2021

Should be solved by this already merged PR:

#4606

This is part of 3.2.13

@github-actions github-actions bot locked and limited conversation to collaborators Oct 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants