Pārlūkot izejas kodu

fix(docs): fix API webview/window class doc example (#8971)

* fix class doc example

* fix class doc example
i-c-b 1 gadu atpakaļ
vecāks
revīzija
9cc014f2df
2 mainītis faili ar 11 papildinājumiem un 18 dzēšanām
  1. 5 5
      tooling/api/src/webview.ts
  2. 6 13
      tooling/api/src/window.ts

+ 5 - 5
tooling/api/src/webview.ts

@@ -93,9 +93,9 @@ export type WebviewLabel = string
  * import { Window } from "@tauri-apps/api/window"
  * import { Webview } from "@tauri-apps/api/webview"
  *
- * // loading embedded asset:
- * const appWindow = new Window('uniqueLabel')
+ * const appWindow = new Window('uniqueLabel');
  *
+ * // loading embedded asset:
  * const webview = new Webview(appWindow, 'theUniqueLabel', {
  *   url: 'path/to/page.html'
  * });
@@ -112,9 +112,9 @@ export type WebviewLabel = string
  * });
  *
  * // emit an event to the backend
- * await webview.emit("some event", "data");
+ * await webview.emit("some-event", "data");
  * // listen to an event from the backend
- * const unlisten = await webview.listen("event name", e => {});
+ * const unlisten = await webview.listen("event-name", e => {});
  * unlisten();
  * ```
  *
@@ -136,7 +136,7 @@ class Webview {
    * import { Window } from '@tauri-apps/api/window'
    * import { Webview } from '@tauri-apps/api/webview'
    * const appWindow = new Window('my-label')
-   * const webview = new Window(appWindow, 'my-label', {
+   * const webview = new Webview(appWindow, 'my-label', {
    *   url: 'https://github.com/tauri-apps/tauri'
    * });
    * webview.once('tauri://created', function () {

+ 6 - 13
tooling/api/src/window.ts

@@ -235,14 +235,9 @@ export type WindowLabel = string
  *
  * @example
  * ```typescript
- * // loading embedded asset:
- * const appWindow = new Window('theUniqueLabel', {
- *   url: 'path/to/page.html'
- * });
- * // alternatively, load a remote URL:
- * const appWindow = new Window('theUniqueLabel', {
- *   url: 'https://github.com/tauri-apps/tauri'
- * });
+ * import { Window } from "@tauri-apps/api/window"
+ *
+ * const appWindow = new Window('theUniqueLabel');
  *
  * appWindow.once('tauri://created', function () {
  *  // window successfully created
@@ -252,9 +247,9 @@ export type WindowLabel = string
  * });
  *
  * // emit an event to the backend
- * await appWindow.emit("some event", "data");
+ * await appWindow.emit("some-event", "data");
  * // listen to an event from the backend
- * const unlisten = await appWindow.listen("event name", e => {});
+ * const unlisten = await appWindow.listen("event-name", e => {});
  * unlisten();
  * ```
  *
@@ -272,9 +267,7 @@ class Window {
    * @example
    * ```typescript
    * import { Window } from '@tauri-apps/api/window';
-   * const appWindow = new Window('my-label', {
-   *   url: 'https://github.com/tauri-apps/tauri'
-   * });
+   * const appWindow = new Window('my-label');
    * appWindow.once('tauri://created', function () {
    *  // window successfully created
    * });