当前位置: 首页 > article >正文

tauri2中创建新的窗口方式,和tauri1不一样了哦

看官方javascript的api文档:window | Tauri 

tauri中的rust文档:https://docs.rs/tauri/latest/tauri/index.html

tauri.config.json定义文档:Configuration | Tauri

tauri可用插件:tauri-apps repositories · GitHub

在前端页面创建窗口示例:

import { Window } from "@tauri-apps/api/window"

const appWindow = new Window('theUniqueLabel');

appWindow.once('tauri://created', function () {
 // window successfully created
});
appWindow.once('tauri://error', function (e) {
 // an error happened creating the window
});

// emit an event to the backend
await appWindow.emit("some-event", "data");
// listen to an event from the backend
const unlisten = await appWindow.listen("event-name", e => {});
unlisten();

在tauri后端rust创建窗口文档:WebviewWindowBuilder in tauri::webview - Rust

示例代码:

#[tauri::command]
async fn create_window(app: tauri::AppHandle) {
  let webview_window = tauri::WebviewWindowBuilder::new(&app, "label", tauri::WebviewUrl::App("index.html".into()))
    .build()
    .unwrap();
}

http://www.kler.cn/a/445961.html

相关文章:

  • 堆【Lecode_HOT100】
  • 【原生js案例】让你的移动页面实现自定义的上拉加载和下拉刷新
  • RestTemplate远程调用、服务注册、
  • [Unity] 【VR】【游戏开发】在VR中使用New Input System获取按键值的完整教程
  • Git实用指南(精简版)
  • Vulhub:Redis[漏洞复现]
  • 【HTML】Shadow DOM
  • 对uniApp 组件 picker-view 的二次封装,实现日期,时间、自定义数据滚动选择,容易扩展
  • C#代码实现把中文录音文件(.mp3 .wav)转为文本文字内容
  • 使用Unity做一个3D吃豆人小游戏
  • 【人工智能】物联网技术及其应用
  • 电商店铺数据集成到金蝶云星辰V2的实践经验分享
  • k8s-1.28.1证书更新到100年-cenots7.9
  • 卷积神经网络-填充+步长
  • 差分数组的使用
  • 工业主板产品线的多样性与应用
  • 【数据分析之pandas】
  • go语言学习之错误记录-1、GOPROXY
  • 原生开发vs混合开发
  • 【上传文件过大进行的切片式上传】
  • Oracle 表连接原理与优化
  • Qt 开发之蓝牙连接
  • hackme靶机保姆及攻略
  • elasticsearch Flattened 使用
  • JS面向对象及继承
  • 【第六节】Git Flow:分支管理模型与工作流程