elementUtil.js 486 Bytes
Newer Older
李晓兵's avatar
李晓兵 committed
1
export default{
JingChao's avatar
JingChao committed
2
  createElement: function (marker, tag) {
李晓兵's avatar
李晓兵 committed
3 4 5 6 7
    let el = document.createElement(tag || 'div')
    el.setAttribute(marker, '')
    document.body.appendChild(el)
  },

JingChao's avatar
JingChao committed
8
  removeElement: function (marker) {
李晓兵's avatar
李晓兵 committed
9
    let el = document.querySelector(marker) || document.querySelector(`[${marker}]`)
JingChao's avatar
JingChao committed
10
    if (el) { document.body.removeChild(el) }
李晓兵's avatar
李晓兵 committed
11
  },
JingChao's avatar
JingChao committed
12
  timeout: function (duration = 0) {
李晓兵's avatar
李晓兵 committed
13
    return new Promise((resolve, reject) => {
JingChao's avatar
JingChao committed
14
      setTimeout(resolve, duration)
李晓兵's avatar
李晓兵 committed
15
    })
JingChao's avatar
JingChao committed
16
  },
李晓兵's avatar
李晓兵 committed
17
}