Tauri 前端全局通道
2024-01-26 10:00 更新
要使用全局事件通道,请导入模块并使用 and 函数:event
emit
listen
import { emit, listen } from '@tauri-apps/api/event'
// listen to the `click` event and get a function to remove the event listener
// there's also a `once` function that subscribes to an event and automatically unsubscribes the listener on the first event
const unlisten = await listen('click', (event) => {
// event.event is the event name (useful if you want to use a single callback fn for multiple event types)
// event.payload is the payload object
})
// emits the `click` event with the object payload
emit('click', {
theMessage: 'Tauri is awesome!',
})
以上内容是否对您有帮助:
← Tauri 前端
更多建议: