vue code snippet
  • vue code snippet
  • Vue code snippet
    • 在函数式组件的render函数中透传slot
    • 把父组件的slot传给子组件
    • refs支持响应式编程
  • JS code snippet
    • 用a标签触发下载
Powered by GitBook
On this page

Was this helpful?

  1. JS code snippet

用a标签触发下载

const data = "test string"
const blob = new Blob([data], { type: 'text/plain' })
const link = document.createElement('a')
link.href = window.URL.createObjectURL(blob)
link.setAttribute('target', '_blank')
link.download = 'accountSummary.txt'
document.body.appendChild(link)
link.click()
setTimeout(() => {
  document.body.removeChild(link)
}, 0)
const link = document.createElement('a')
link.href = url
link.setAttribute('target', '_blank')
link.download = name
document.body.appendChild(link)
link.click()
setTimeout(() => {
  document.body.removeChild(link)
}, 0)
Previousrefs支持响应式编程

Last updated 2 years ago

Was this helpful?