实现代码:

let timer: number;
let flag = false;
let obj = document.querySelector('div') as HTMLElement;
 
obj.addEventListener('touchstart', function () {
    timer = window.setTimeout(function () {
        flag = true;
    }, 300)
})
 
obj.addEventListener('touchend', function () {
    window.clearTimeout(timer)
    if (!flag) {
        flag = false;
        console.log('click!')
        return;
    }
    flag = false
    console.log('long press');
})