nicecode-v2/packages/material/es/utils/index.js
2024-04-22 15:44:52 +08:00

14 lines
570 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 可应用于页面跳转以及文件下载
// 第一个参数:文件的下载路径/要跳转页面的路径(可携带参数)
// 第二个参数是否新打开一个页面true为新开一个页面false是在当前页面进行操作
export var createAElement = function createAElement(url, isBlank) {
var newLink = document.createElement('a');
newLink.className = 'create-link';
newLink.href = url;
if (isBlank) {
newLink.target = '_blank';
}
document.body.appendChild(newLink);
newLink.click();
document.body.removeChild(newLink);
};