@netjoy/ex2json
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

一、使用

  • 安装

    $ npm i @netjoy/ex2json
  • 引入

    import ex2json from "@netjoy/ex2json";
  • 使用

    <template>
      <input type="file" @change="read" />
    </template>
    
    <script>
      import ex2json from "ex2json";
      export default {
        methods: {
          read(e) {
            // 文件对象
            const file = e.target.files[0];
            // 转成成 json
            ex2json.parse(file, (code, res) => {
              console.log(code, res);
            });
          },
        },
      };
    </script>
  • 可能会遇到的问题:

    • Vue3 报错 Module not found: Error: Can't resolve 'fs' in 'xxx',可在 vue.config.js 中新增以下配置即可:

      const { defineConfig } = require('@vue/cli-service')
      module.exports = defineConfig({
        transpileDependencies: ...,
        devServer: { ... },
        // 下面这段配置添加上即可
        configureWebpack: {
          resolve: { fallback: { fs: false } }
        }
      })

Readme

Keywords

Package Sidebar

Install

npm i @netjoy/ex2json

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

1.23 MB

Total Files

8

Last publish

Collaborators

  • netjoy