Created
July 11, 2018 06:30
-
-
Save viko16/6b682bcd54e930b3947c1fcb5110024c to your computer and use it in GitHub Desktop.
插入链接的写法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 传统写法 | |
const el = document.createElement('link') | |
el.rel = 'stylesheet' | |
el.href = 'main.css' | |
document.head.appendChild(el) | |
// 单条写法 | |
document.head.appendChild(Object.assign( | |
document.createElement('link'), | |
{ rel: 'stylesheet', href: 'main.css' }, | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment