window.open被浏览器拦截解决方案

常用方法   2024-07-20 11:23   51   0  
/**
 * window.open(url)打开链接被浏览器拦截解决方案
 * @param url
 */
export function addBlankPath(url) {
    const a = document.createElement('a')
    a.href = url  // 窗口的链接
    a.target = '_blank'
    document.body.appendChild(a)
    a.click()
    document.body.removeChild(a)
}