Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio code 将图标添加到VSCode树视图_Visual Studio Code_Vscode Extensions - Fatal编程技术网

Visual studio code 将图标添加到VSCode树视图

Visual studio code 将图标添加到VSCode树视图,visual-studio-code,vscode-extensions,Visual Studio Code,Vscode Extensions,我正在尝试设置树视图的图标,但它不起作用。这是我的密码: export class MyClass extends vscode.TreeItem { constructor( public readonly label: string, private version: string, public readonly collapsibleState: vscode.TreeItemCollapsibleState, public readonly co

我正在尝试设置树视图的图标,但它不起作用。这是我的密码:

export class MyClass extends vscode.TreeItem {
    constructor(
    public readonly label: string,
    private version: string,
    public readonly collapsibleState: vscode.TreeItemCollapsibleState,
    public readonly command?: vscode.Command) 
    {
      super(label, collapsibleState);
    }

 get tooltip(): string {
        return `tooltip works`;
    }

  iconPath = {
        light: path.join(__filename, '..', 'resources', 'light', 'dependency.svg'),
        dark: path.join(__filename, '..', 'resources', 'dark', 'dependency.svg')
    };
}
还有什么我需要配置的吗


我遇到了完全相同的问题,请将另一个
“…”
添加到您的路径连接

iconPath = {
        light: path.join(__filename, '..', '..', 'resources', 'light', 'dependency.svg'),
        dark: path.join(__filename, '..', '..', 'resources', 'dark', 'dependency.svg')
    };
这是因为所有路径都是从
out/
目录中引用的,因此您需要再向上1步才能访问资源

谢谢。它起作用了。“所有路径都是从out目录引用的”正是解释为什么它不起作用的原因。