采纳答案成功!
向帮助你的同学说点啥吧!感谢那些助人为乐的人
setTimeOut(() => { messageInstance.unmount(mountNode) document.body.removeChild(mountNode) }, timeout)
同学你好 组件实例上应该是有这个方法的 你选择 messageInstance 点击右键 选择第二个 go to type difinition 去看一下。我的是这样的。是能看到 unmount 方法的
export declare interface App<HostElement = any> { version: string; config: AppConfig; use(plugin: Plugin_2, ...options: any[]): this; mixin(mixin: ComponentOptions): this; component(name: string): Component | undefined; component(name: string, component: Component): this; directive(name: string): Directive | undefined; directive(name: string, directive: Directive): this; mount(rootContainer: HostElement | string, isHydrate?: boolean): ComponentPublicInstance; unmount(rootContainer: HostElement | string): void; provide<T>(key: InjectionKey<T> | string, value: T): this; _uid: number; _component: ConcreteComponent; _props: Data | null; _container: HostElement | null; _context: AppContext; }
不知道你的是怎样的,如果完全不一样,说明你的类型定义文件有可能有问题,你可以尝试重装一次 vue试试。
```js export declare interface App<HostElement = any> { version: string; config: AppConfig; use(plugin: Plugin_2, ...options: any[]): this; mixin(mixin: ComponentOptions): this; component(name: string): Component | undefined; component(name: string, component: Component): this; directive(name: string): Directive | undefined; directive(name: string, directive: Directive): this; mount(rootContainer: HostElement | string, isHydrate?: boolean): ComponentPublicInstance; umount(): void; provide<T>(key: InjectionKey<T> | string, value: T): this; _uid: number; _component: ConcreteComponent; _props: Data | null; _container: HostElement | null; _context: AppContext; } ```
```shell npm uninstall -g @vue/cli rm -rf node_modules npm install -g @vue/cli npm install 这样操作以后,runtime-core.d.ts 下的 umount(): void; 还是这样。 手动填加 unmount(rootContainer: HostElement | string): void; 就行了。 不明白为什么会少 parms .... ```
登录后可查看更多问答,登录/注册
带你完成前后端分离复杂项目,率先掌握 vue3 造轮子技能
1.4k 2
1.1k 2
757 17
1.2k 17
1.7k 15