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();
}
相关推荐
永不停歇的蜗牛18 分钟前
Maven的POM文件相关标签作用
服务器·前端·maven
Erwin Rommel55926 分钟前
nginx的https服务搭建实验
服务器·nginx·https
mzhan01732 分钟前
Linux: console: printk: console_no_auto_verbose
linux·运维·服务器
q***441535 分钟前
Spring Security 新版本配置
java·后端·spring
芳草萋萋鹦鹉洲哦36 分钟前
【vue/js】文字超长悬停显示的几种方式
前端·javascript·vue.js
o***741743 分钟前
Springboot中SLF4J详解
java·spring boot·后端
河南博为智能科技有限公司1 小时前
高集成度国产八串口联网服务器:工业级多设备联网解决方案
大数据·运维·服务器·数据库·人工智能·物联网
孤独斗士1 小时前
maven的pom文件总结
java·开发语言
Savvy..1 小时前
天机学堂-Day01
linux·服务器·网络
HIT_Weston1 小时前
47、【Ubuntu】【Gitlab】拉出内网 Web 服务:Nginx 事件驱动分析(一)
前端·ubuntu·gitlab