Category - Html

2021-05-28 15:13:22    7    0    0
2021-05-21 08:02:42    9    0    0
  1. .rflex {
  2. display: -webkit-box;
  3. display: -ms-flexbox;
  4. display: flex;
  5. -webkit-box-orient: vertical;
  6. -ms-flex-direction: row;
  7. -webkit-flex-direction: row;
  8. flex-direction: row;
  9. }
  10. .cflex {
  11. display: -webkit-box;
  12. display: -ms-flexbox;
  13. display: flex;
  14. -webkit-box-orient: vertical;
  15. -ms-flex-direction: column;
  16. -webkit-flex-direction: column;
  17. flex-direction: column;
  18. }
  19. .flex_justify_between {
  20. -webkit-box-pack: space-between;
  21. -ms-flex-pack: space-between;
  22. -webkit-justify-content: space-between;
  23. justify-content: space-between;
  24. }
  25. .flex_justify_around {
  26. -webkit-box-pack: space-around;
  27. -ms-flex-pack: space-around;
  28. -webkit-justify-content: space-around;
  29. justify-content: space-around;
  30. }
  31. .flex_justify_center {
  32. -webkit-box-pack: center;
  33. -ms-flex-pack: center;
  34. -webkit-justify-content: center;
  35. justify-content: center;
  36. }
  37. .flex_justify_end {
  38. -webkit-box-pack: end;
  39. -moz-justify-co
2021-05-17 10:08:34    5    0    0

注意, 跨域的图片地址不能下载, 会直接打开, 没跨域的可以下载

第一个: 图片下载点击会打开新标签页, 解决: href的url后面加上?response-content-type=application/octet-stream

  1. <a
  2. :href="item.url + '?response-content-type=application/octet-stream'"
  3. :download="item.name">点击下载</a>

第二个

  1. // url为下载地址
  2. fetch(url, { method: 'get', headers: { 'Content-Type': 'image/jpeg' } }).then(
  3. res => res.blob().then(blob => {
  4. var reader = new FileReader()
  5. reader.readAsDataURL(blob) // 转换为base64,可以直接放入a标签href
  6. reader.onload = function (e) {
  7. var downItem = document.createElement('a') // 转换完成,创建一个a标签用于下载
  8. downItem.style.display = "none"
  9. downItem.download = name
  10. downItem.href = String(e.target.result)
  11. downItem.click()
  12. downItem.remove()
  13. // document.body.appendChild(downItem);
  14. // downItem.click()
  15. // document.body.removeChild(downItem);
  16. }
  17. })
  18. )

通用方法: 跨域图片下载, 未跨域的也能下载

2019-11-14 07:46:28    23    0    0
var str = '如果有一天休息休息下cvcvx,'+"\n"+ ' 那么~~~'; 这种写法在html中是会被识别为"如果有一天休息休息下`cvcvx,\n 那么~~~" 那么如何保证其这么写会被识别,只需要在该div的样式中加入 `white-space":"pre"` 这个样式