动态添加script标签,并防止缓存添加时间戳

<script>
  window.onload = function () {
    var el = document.createElement('script')
    var el_html = document.querySelector('html')
    var timetemp = new Date().getTime()
    el.type = 'text/javascript'
    el.src = './index.js?timetemp=' + timetemp
    el_html.appendChild(el)
  }
</script>
posted @ 2020-05-18 15:55  有肌肉的小眼睛  阅读(1209)  评论(0)    收藏  举报