下面是package.json
中的contributes
对象
"contributes": {
"viewsWelcome": [
{
"view": "notesView",
"contents": "No node dependencies found [learn more](https://www.npmjs.com/).\n[Add Dependency](command:notesView.addNote)",
"when": "notesView.notesLen == 0"
}
],
"viewsContainers": {
"activitybar": [
{
"id": "side-notes",
"title": "Side Notes",
"icon": "media/notesIcon.svg"
}
]
},
"views": {
"side-notes": [
{
"id": "notesView",
"name": "Notes",
"type": "webview"
}
]
},
"menus": {
"view/title": [
{
"command": "notesView.addNote",
"group": "navigation",
"when": "view == notesView && notesView.notesLen == 0"
}
]
},
"commands": [
{
"command": "notesView.addNote",
"title": "Add Side Note",
"icon": "$(add)"
}
]
这是extension.js
import * as vscode from 'vscode';
export function activate(context: vscode.ExtensionContext) {
vscode.commands.executeCommand('setContext', 'notesView.notesLen', 0);
context.subscriptions.push(
vscode.commands.registerCommand('notesView.addNote', async () => {
vscode.window.showInformationMessage('Hello World!');
}));
}
预期行为是显示欢迎内容。
但是,视图会一直加载下去。
1条答案
按热度按时间k5ifujac1#
输入
package.json
视图类型设置为
webview
,需要HTML内容。这将导致视图永远加载。类型应为
tree