preview.vue 996 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <template>
  2. <div class="img-list">
  3. <template v-for="src in value">
  4. <video v-if="type(src)" :src="src | host" :key="src" controls></video>
  5. <el-image class="img" v-else :src="src | host" :key="src" :preview-src-list="src | hostList">
  6. <div slot="placeholder" class="img-loading"><i class="el-icon-loading"></i></div>
  7. <div slot="error" class="image-slot"><i class="el-icon-picture-outline"></i></div>
  8. </el-image>
  9. </template>
  10. </div>
  11. </template>
  12. <script>
  13. //图片、视频预览组件
  14. export default {
  15. props: {
  16. value: {
  17. type: Array,
  18. default() {
  19. return [];
  20. }
  21. }
  22. },
  23. methods: {
  24. //类型
  25. type(value = '') {
  26. const t = value.split('.').pop();
  27. switch (t) {
  28. case 'mp4':
  29. case 'ogg':
  30. return true;
  31. break;
  32. default:
  33. return false;
  34. break;
  35. }
  36. }
  37. }
  38. };
  39. </script>
  40. <style lang="less" scoped>
  41. .img-loading,
  42. .image-slot {
  43. display: flex;
  44. font-size: .5rem;
  45. justify-content: center;
  46. align-items: center;
  47. padding: .5rem 0;
  48. }
  49. </style>