New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

gos-viewer

Package Overview
Dependencies
Maintainers
4
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gos-viewer

A file viewer that supports multiple file formats.

latest
npmnpm
Version
1.0.0-alpha.17
Version published
Maintainers
4
Created
Source

gos-viewer

一个支持多文件格式的web文件查看器

安装

npm install gos-viewer -S

或者

yarn add gos-viewer

快速上手

main.js 引入

import GosViewer from 'gos-viewer'
Vue.use(GosViewer)

在页面中使用

  • 模态框形式
<template>
  <div>
    <input
      ref="file"
      class="file-select"
      type="file"
      @change="handleChange"
    />
  </div>
</template>

<script>
export default {
  name: 'DemoPage',
  data () {
    return {
      file: null
    }
  },
  created () {
    // 初始化文件查看器
    this.$gosViewer.init()
    // 监听关闭事件
    this.$gosViewer.onWindowClose(() => {
      // 重置文件表单
      this.$refs.file.value = ''
    })
  },
  methods: {
    handleChange (e) {
      // 获取选择的文件
      const [file] = e.target.files
      // 打开文件
      this.$gosViewer.open({
        data: file
      })
    }
  }
}
</script>


  • 嵌入模式(详见examples)
<script>
export default {
  name: "TestEmbedMode",
  data() {
    return {
      file: {
        file: new File(["666"], "index.txt", {
          type: "text/plain",
        }), // 文件
        type: "text", // 打开类型
      },
    };
  },
};
</script>

<template>
  <div>
    <gos-viewer
      ref="gosViewer"
      width="1200px"
      height="800px"
      v-model="file"
      style="border: 1px solid #ddd"
    ></gos-viewer>
  </div>
</template>

Keywords

vue

FAQs

Package last updated on 25 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts