Jak*_*son 3 visual-studio-code vscode-extensions
根据API文档,“消息”框可以带有第二个参数:用作消息框上的操作的字符串数组(通常只有一个关闭按钮/操作):
https://code.visualstudio.com/docs/extensionAPI/vscode-api#_window
showInformationMessage(message: string, ...items: string[]): Thenable<string>
Run Code Online (Sandbox Code Playgroud)
所以我尝试了这个:
vscode.window.showInformationMessage('hello world', ['test','taco','cheeseburger'], function(value){
console.log(value + " was clicked");
});
Run Code Online (Sandbox Code Playgroud)
但这似乎不起作用。我收到消息框,并像往常一样关闭按钮。但是在关闭按钮的左侧,似乎是另一个没有文本或标题的单个按钮。
另一个函数定义是:
showInformationMessage<T extends MessageItem>(message: string, ...items: T[]): Thenable<T>
Run Code Online (Sandbox Code Playgroud)
所以我尝试了这样的事情:
let message: vscode.MessageItem = { title: 'testing' };
vscode.window.showInformationMessage('hello', [message], function(value){
console.log(value + " was clicked");
});
Run Code Online (Sandbox Code Playgroud)
但这似乎也不起作用。关于此的文档很少,所以我无法弄清楚。
小智 9
vscode.window
.showInformationMessage('hello', 'test', 'taco', 'cheeseburger')
.then(selection => {
console.log(selection);
});
Run Code Online (Sandbox Code Playgroud)
要么
vscode.window
.showInformationMessage('hello', ...['test', 'taco', 'cheeseburger'])
.then(selection => {
console.log(selection);
});
Run Code Online (Sandbox Code Playgroud)
两者都导致如下所示的对话框:

| 归档时间: |
|
| 查看次数: |
1071 次 |
| 最近记录: |