一、安装
npm install uuid --save
yarn add uuid
二、使用
<template>
<div>
<p>生成的 UUID: {{ uuid }}</p>
</div>
</template>
<script>
import { v4 as uuidv4 } from 'uuid';
export default {
data() {
return {
uuid: null
};
},
mounted() {
this.uuid = uuidv4(); // 生成 UUIDv4
}
};
</script>