NativeScript-Vue with Typescript in VSCode with Vetur: Alert with then giving 属性 'then' does not exist on type 'void'

NativeScript-Vue with Typescript in VSCode with Vetur: Alert with then giving Property 'then' does not exist on type 'void'

我正在使用 VSCode 和 Vetur。这是我的代码:

alert({
  title: 'Success!',
  message: 'Account created successfully',
  okButtonText: 'Okay'
  }).then(() => {
  console.log('Alert dialog closed!');
})

我收到错误 Property 'then' does not exist on type 'void' Vetur(2339)

我只是按照此处文档中的说明操作:https://nativescript-vue.org/en/docs/elements/dialogs/alert/

知道发生了什么事吗?

编辑 Nativescript 7:

import {Dialogs} from "@nativescript/core";

然后使用

Dialogs.alert({
  foo
});

或对话框模块中您需要的任何内容。

原回答:

确保

import { alert } from 'tns-core-modules/ui/dialogs'

编辑: 或(感谢 ayudh)

import { alert } from '@nativescript/core/ui/dialogs'