[英]HTML link starting with “vscode:” to open a file in Visual Studio Code
根据问题#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>
这应与在控制台中键入以下命令具有相同的效果:
code -g -r /path/to/my/file.md
但是我得到的是不同的:
单击后:
然后单击“打开Visual Studio代码”,然后打开应用程序(或放在前台),但未打开文件。
我错过了什么?
我已经尝试过<a href="vscode:///path/to/my/file.md">
但是结果是一样的。
我在以下答案中找到了解决方案:您需要在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.