繁体   English   中英

在JS中安装npm uuid后无法调用uuid function

[英]can't call uuid function after install npm uuid in JS

在JS中安装npm uuid后,我无法调用uuid function,使用electron

这是我安装时终端上的消息,我不知道这是否正确安装

$ npm install uuid
npm WARN pemrograman_visual2@1.0.0 No description
npm WARN pemrograman_visual2@1.0.0 No repository field.

+ uuid@7.0.3
updated 1 package and audited 120 packages in 1.746s

2 packages are looking for funding
  run `npm fund` for details

found 1 low severity vulnerability
  run `npm audit fix` to fix them, or `npm audit` for details

这就是我称之为 function 的地方

ipcMain.on("appointment:create", (event, appointment) => {
    appointment["id"] = uuid();
    appointment["done"] = 0;
    allAppointment.push(appointment);

    CreateWindow.close();

    console.log(allAppointment);
});

但是当我使用 $npm start 运行程序时,它说 TypeError: uuid is not a function

文档中导入 uuid 的方式:

使用导入/导出语法:

import { v4 as uuid } from 'uuid';
uuid();

使用 commonJs 语法:

const uuid = require('uuid').v4;
uuid();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM