preview.vue 789 B

12345678910111213141516171819202122232425262728293031
  1. <template>
  2. <view>
  3. <ss-preview :fileUrl="fileUrl" :fileType="fileType" :imageList="imageList"></ss-preview>
  4. </view>
  5. </template>
  6. <script>
  7. export default {
  8. data() {
  9. return {
  10. fileUrl: '',
  11. fileType:'',
  12. imageList:[],
  13. }
  14. },
  15. onLoad(option) {
  16. let options = JSON.parse(decodeURIComponent(option.item))
  17. this.fileType = options.type;
  18. if(options.type === '1') return this.imageList = options.src
  19. this.fileUrl = options.src;
  20. //此处仅为.doc,.docx,.xls,.xlsx示例,通过服务端接口把相关文件转换为pdf文件流
  21. // let types = options.src.substr(options.src.lastIndexOf('.'));
  22. // if(types !== '.pdf'){
  23. // this.fileUrl = `https://xxxx?file==${encodeURIComponent(options.src)}`
  24. // }
  25. },
  26. }
  27. </script>
  28. <style>
  29. </style>