开发文档Umo Viewer事件列表

事件列表

本章介绍 Umo Viewer 的所有事件。

使用示例

<template>
  <umo-viewer
    v-bind="options"
    @close="onClose"
    @edit="onEdit"
    @validate-password="onValidatePassword"
  />
</template>
 
<script setup>
import { ref } from 'vue'
import { UmoViewer } from '@umoteam/viewer'
 
const options = ref({
  // 配置项
  lang: 'zh-CN',
  // ...
})
 
// 关闭事件,例如在关闭事件中关闭弹窗
const onClose = () => {
  console.log('关闭事件')
}
 
// 编辑事件
const onEdit = () => {
  console.log('编辑事件')
}
 
// 验证密码事件
const onValidatePassword = (password) => {
  if (password === '123456') {
    return true
  }
  return false
}
</script>

事件说明

onClose

说明: 点击关闭按钮时触发的事件,通常用于关闭弹窗。

类型: () => void

默认值: undefined

onEdit

说明: 点击编辑按钮时触发的事件。如果配置了editable 选项,则需要配置该事件。

类型: () => void

默认值: undefined

onValidatePassword

说明: 当文档需要密码访问时,用于验证密码的事件。如果密码正确,则需要返回 true,否则返回 false。该事件支持异步验证。

类型: (password: string) => boolean | Promise<boolean>

默认值: undefined