当前位置:   article > 正文

uniapp:图片/文件预览,截取图片路径,展示图片名称_uni 图片预览

uni 图片预览
  1. previewImage(e) {
  2. var that = this
  3. that.imageUrl = that.risun.utils.dealImg(e)
  4. let index = that.imageUrl.lastIndexOf('.')
  5. let filename = that.imageUrl.slice(0, index) && index !== -1 ? that.imageUrl
  6. .slice(index) : ''
  7. console.log(filename)
  8. if (filename == '.png' || filename == '.jpeg' || filename == '.bmp' ||
  9. filename == '.psd' || filename == '.jpg') {
  10. that.current.push(that.imageUrl)
  11. uni.previewImage({
  12. current: index,
  13. urls: that.current
  14. })
  15. } else {
  16. uni.downloadFile({
  17. url: that.imageUrl, //文件链接
  18. success: function(res) {
  19. var filePath = res.tempFilePath;
  20. console.log(res)
  21. uni.openDocument({
  22. filePath: filePath,
  23. showMenu: true,
  24. success: function(res) {
  25. console.log('打开文档成功', res);
  26. }
  27. });
  28. }
  29. });
  30. }
  31. },

截取路径

let fileName = item.split('/').pop().split('_').shift()
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/空白诗007/article/detail/758935
推荐阅读