Use joinUri in webview docs
Fixes https://github.com/microsoft/vscode/issues/173448
This commit is contained in:
Родитель
f88613f7cf
Коммит
21dd59a72b
|
@ -451,8 +451,8 @@ const panel = vscode.window.createWebviewPanel(
|
|||
vscode.ViewColumn.One);
|
||||
|
||||
// Get the content Uri
|
||||
const catGifUri = panel.webview.asWebviewUri(vscode.Uri.file(
|
||||
path.join(context.extensionPath, 'media', 'cat.gif')));;
|
||||
const catGifUri = panel.webview.asWebviewUri(
|
||||
vscode.Uri.joinPath(context.extensionUri, 'media', 'cat.gif'));
|
||||
|
||||
// Reference it in your content
|
||||
panel.webview.html = `<!DOCTYPE html>
|
||||
|
|
|
@ -438,7 +438,6 @@ Imagine that we want to start bundling the cat gifs into our extension rather pu
|
|||
|
||||
```ts
|
||||
import * as vscode from 'vscode';
|
||||
import * as path from 'path';
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
context.subscriptions.push(
|
||||
|
@ -451,9 +450,7 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
);
|
||||
|
||||
// Get path to resource on disk
|
||||
const onDiskPath = vscode.Uri.file(
|
||||
path.join(context.extensionPath, 'media', 'cat.gif')
|
||||
);
|
||||
const onDiskPath = vscode.Uri.joinPath(context.extensionUri, 'media', 'cat.gif');
|
||||
|
||||
// And get the special URI to use with the webview
|
||||
const catGifSrc = panel.webview.asWebviewUri(onDiskPath);
|
||||
|
@ -489,7 +486,6 @@ We can use `localResourceRoots` to restrict **Cat Coding** webviews to only load
|
|||
|
||||
```ts
|
||||
import * as vscode from 'vscode';
|
||||
import * as path from 'path';
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
context.subscriptions.push(
|
||||
|
@ -501,14 +497,12 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
{
|
||||
// Only allow the webview to access resources in our extension's media directory
|
||||
localResourceRoots: [
|
||||
vscode.Uri.file(path.join(context.extensionPath, 'media'))
|
||||
vscode.Uri.joinPath(context.extensionPath, 'media')
|
||||
]
|
||||
}
|
||||
);
|
||||
|
||||
const onDiskPath = vscode.Uri.file(
|
||||
path.join(context.extensionPath, 'media', 'cat.gif')
|
||||
);
|
||||
const onDiskPath = vscode.Uri.joinPath(context.extensionUri, 'media', 'cat.gif');
|
||||
const catGifSrc = panel.webview.asWebviewUri(onDiskPath);
|
||||
|
||||
panel.webview.html = getWebviewContent(catGifSrc);
|
||||
|
|
Загрузка…
Ссылка в новой задаче