
Just introduce and use it directly in the mini program like other packages.
Tips:
If the mini program does not support third-party packages, you need to write your own method to export.
This method is available for personal testing. The format of the generated uuid is:
7b611f1e-6a5f-4501-b658-27295f275066
Create file—_uuid.js
const uuid = function () {
var s = [];
var hexDigits = "0123456789abcdef";
for (var i = 0; i < 36; i++) {
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
}
s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
s[8] = s[13] = s[18] = s[23] = "-";
var uuid = s.join("");
return uuid
}
// 需要导出
module.exports = {
uuid
}Use:
// 引入
// 使用相对路径引入创建的文件
const util = require('../utils/_uuid.js');
// 使用时直接使用即可
getUUid() {
const uuid = util.uuid();
// 可打印值看看
// `7b611f1e-6a5f-4501-b658-27295f275066`
}Related recommendations: Mini Program Development Tutorial
The above is the detailed content of How to use UUID in applet. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Dreamweaver Mac version
Visual web development tools

Atom editor mac version download
The most popular open source editor





