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();
}
相关推荐
言慢行善9 分钟前
sqlserver模糊查询问题
java·数据库·sqlserver
专吃海绵宝宝菠萝屋的派大星14 分钟前
使用Dify对接自己开发的mcp
java·服务器·前端
爱分享的阿Q15 分钟前
Rust加WebAssembly前端性能革命实践指南
前端·rust·wasm
蓝黑202016 分钟前
Vue的 value=“1“ 和 :value=“1“ 有什么区别
前端·javascript·vue
小李子呢021125 分钟前
前端八股6---v-model双向绑定
前端·javascript·算法
大数据新鸟32 分钟前
操作系统之虚拟内存
java·服务器·网络
Tong Z34 分钟前
常见的限流算法和实现原理
java·开发语言
凭君语未可37 分钟前
Java 中的实现类是什么
java·开发语言
He少年39 分钟前
【基础知识、Skill、Rules和MCP案例介绍】
java·前端·python
史迪仔011242 分钟前
[QML] QML IMage图像处理
开发语言·前端·javascript·c++·qt