[英]HTML link starting with “vscode:” to open a file in Visual Studio Code
According to issue #4883 and PR #15320 you can create vscode:/
links in your HTML: 根据问题#4883和PR #15320,您可以在HTML中创建vscode:/
链接:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<h1>Test</h1>
<a href="vscode://path/to/my/file.md">open file.md in vscode</a>
</body>
</html>
This should have the same effect than typing following in the console: 这应与在控制台中键入以下命令具有相同的效果:
code -g -r /path/to/my/file.md
But what I get is different: 但是我得到的是不同的:
After click: 单击后:
And after clicking on "Open Visual Studio Code", then the application is opened (or put in the foreground) but the file is not opened. 然后单击“打开Visual Studio代码”,然后打开应用程序(或放在前台),但未打开文件。
What did I miss? 我错过了什么?
I have tried <a href="vscode:///path/to/my/file.md">
but the result is the same. 我已经尝试过<a href="vscode:///path/to/my/file.md">
但是结果是一样的。
I found the solution in this answer : you need a file/
prefix before the path of your file: 我在以下答案中找到了解决方案:您需要在file/
路径之前添加file/
前缀:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<h1>Test</h1>
<a href="vscode://file/path/to/my/file.md">open file.md in vscode</a>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.