screen_rotation
Copied to Clipboard
<html> <head> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <h3>Vue Js Generate Unique UUId using Native Javascript Method</h3> <div id="app"> <button @click="generateUUID">Generate UUID</button> <p>{{ uuid }}</p> </div> <script type="module"> const app = new Vue({ el: "#app", data() { return { uuid: null } }, methods: { generateUUID() { this.uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { const r = crypto.getRandomValues(new Uint8Array(1))[0] % 16 | 0; const v = c === 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); }); } } }); </script> </body> </html>