// 点击事件由mousedown,mouseup合成
const clickEvents = ['mousedown', 'click', 'mouseup']
// focus 事件由 in,out 合成
const focusEvents = ['focusin', 'focus', 'focusout']
const simulateEvents = (element: HTMLElement, events: string[]) => {
events.forEach((event) => {
element.dispatchEvent(
new MouseEvent(event, {
view: window,
bubbles: true,
cancelable: true,
buttons: 1,
})
)
})
}
网友评论