• 各种格式文件预览


     pdf文件

    <embed:src="文件的地址" style="position:absolute; left: 0; top: 0;" width="100%" height="100%" type="application/pdf">

    图片

    style="width: 100%;height: 100%;object-fit: contain;display: block;-webkit-user-select: none;margin: auto;background-color: hsl(0, 0%, 90%);" :οnlοad="加载成功返回">

    txt

    // 这属于一个通用的预览方式,可以预览多种格式的文件

     

     docx(安装 vue-office/docx)docx文件预览 | vue-office

     xlsx(安装 vue-office/xlsx)xlsx文件预览 | vue-office

     

     视频 安装-ckplayer

    // 调用

     

    1. <!--
    2. * @Description: 视频预览文件
    3. -->
    4. <template>
    5. <div class="playerContainer" ref="playerContainer"></div>
    6. </template>
    7. <script>
    8. import { onMounted, onUnmounted, ref, watch } from 'vue'
    9. export default {
    10. props: {
    11. videoPath: {
    12. type: String,
    13. required: true
    14. }
    15. },
    16. setup (props, ctx) {
    17. const playerContainer = ref(null)
    18. let playerInstance = null
    19. onMounted(() => {
    20. initPlayer()
    21. })
    22. watch(
    23. () => props.videoPath, () => {
    24. // 当路径变化时重新播放新视频
    25. playerInstance && initPlayer()
    26. }
    27. )
    28. onUnmounted(() => {
    29. // 销毁播放器实例
    30. playerInstance && playerInstance.remove()
    31. })
    32. const initPlayer = () => {
    33. // 创建CKPlayer实例
    34. playerInstance = new ckplayer({
    35. container: playerContainer.value,
    36. autoplay: true, // 是否自动播放
    37. video: props.videoPath
    38. })
    39. playerInstance.duration(function (t) {
    40. // t=当前视频总时间
    41. console.log('当前视频总时间-----')
    42. console.log(t)
    43. ctx.emit('ReturnData', t)
    44. })
    45. playerInstance.time(function (t) {
    46. // t=当前播放时间
    47. console.log('当前播放时间-----')
    48. console.log(t)
    49. ctx.emit('ReturnData', t)
    50. })
    51. playerInstance.ended(function () {
    52. // 视频播放已结束
    53. console.log('视频播放已结束')
    54. ctx.emit('ReturnData', false)
    55. })
    56. playerInstance.error(function (obj) {
    57. // 监听到错误,obj=错误内容
    58. console.log('监听到错误-----')
    59. console.log(obj)
    60. ctx.emit('ReturnData', obj)
    61. })
    62. }
    63. return {
    64. playerContainer
    65. }
    66. }
    67. }
    68. </script>
    69. <style scoped>
    70. .card-header {
    71. text-align: center;
    72. border-bottom: 2px dotted #c5c5c5;
    73. }
    74. .playerContainer {
    75. width: 100%;
    76. height: 100%;
    77. overflow: hidden;
    78. }
    79. </style>

  • 相关阅读:
    【visual studio 小技巧】项目属性->生成->事件
    python生成docx文件
    java中比较两个map是否相同
    一起掌握String的用法
    adb 一些命令操作记录
    Gradle基础
    Ask Milvus Anything!聊聊被社区反复@的那些事儿ⅠⅠ
    列式存储的分布式数据库——HBase Shell与SQL实战操作(HBase Master高可用实现)
    【OS】 JAVA 管程 单消费者-生产者问题
    iexcel-excel 读取和写入,解决 excel OOM 问题
  • 原文地址:https://blog.csdn.net/u013486889/article/details/134239957