【发布时间】:2020-03-16 17:31:13
【问题描述】:
我想在{N} Playground Code 中实现 PromptDialog
import dialogs from "tns-core-modules/ui/dialogs";
export default {
methods: {
onButtonTap() {
console.log("Button was pressed");
prompt({
title: "Email Prompt",
message: "Provide your email address:",
okButtonText: "OK",
cancelButtonText: "Cancel",
defaultText: "name@domain.com",
inputType: dialogs.inputType.email
}).then(result => {
console.log(`Dialog result: ${result.result},
text: ${result.text}`);
});
}
},
}
但是 Vetur 给出了以下 Typescript 错误。
Argument of type '{ title: string; message: string; okButtonText: string; cancelButtonText: string; defaultText: string; inputType: string; }' is not assignable to parameter of type 'string'.
这只是nativescript-vue prompt documentation 中的示例代码,但打字稿适应。
基本使用
forgotPassword() {
prompt('Your message to the user', 'Suggested user input').then(result => {
console.log(`Dialog result: ${result.result}, text: ${result.text}`);
});
}
Vetur 错误:
Property 'then' does not exist on type 'string'.
【问题讨论】:
-
prompt接受string作为参数,如果我们在谈论这个:developer.mozilla.org/en-US/docs/Web/API/Window/prompt -
PromptDialog 如{NativeScript} Playground Code
-
暗示API的类型声明不正确
标签: typescript vue.js nativescript nativescript-vue