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

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

javascript 复制代码
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

示例代码:

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();
}
相关推荐
ji_shuke几秒前
CloudFront 跨域问题(CORS)的几种解决方式
服务器·cloudfront
子非鱼@Itfuture9 分钟前
`<T> T execute(...)` 泛型方法 VS `TaskExecutor<T>` 泛型接口对比分析
java·开发语言
2601_949816169 分钟前
spring.profiles.active和spring.profiles.include的使用及区别说明
java·后端·spring
IMPYLH12 分钟前
Linux 的 install 命令
linux·运维·服务器·bash
寻道模式13 分钟前
【运维心得】“龙虾”非本地访问的坑
运维·服务器
林恒smileZAZ17 分钟前
前端大屏适配方案:rem、vw/vh、scale 到底选哪个?
开发语言·前端·css·css3
疯狂成瘾者20 分钟前
接口规范设计:返回体 + 错误码 + 异常处理
java·状态模式
阿Y加油吧23 分钟前
LeetCode 二叉搜索树双神题通关!有序数组转平衡 BST + 验证 BST,小白递归一把梭
java·算法·leetcode
QQ51100828527 分钟前
基于区块链的个人医疗咨询挂号信息系统vue
前端·vue.js·区块链
项目帮27 分钟前
Java毕设选题推荐:基于springboot区块链的电子病历数据共享平台设计与实现【附源码、mysql、文档、调试+代码讲解+全bao等】
java·spring boot·课程设计