VitorLuizC / vue-uuid

Add UUID to Vue instance.
MIT License
73 stars 7 forks source link

Import Specific Version #7

Closed cliftonlabrum closed 4 years ago

cliftonlabrum commented 4 years ago

I want to use v4() globally in my Vue app. Is there a way to import this so that the $uuid default is the same thing as using $uuid.v4() but without having to remember the .v4() everywhere?

Thanks!

VitorLuizC commented 4 years ago

To do so you just have to import uuid's v4 and define into $uuid attribute of Vue's prototype.

import uuid from 'uuid/v4';
import Vue from 'vue';

Vue.prototype.$uuid = uuid;
cliftonlabrum commented 4 years ago

Perfect, thank you!