Forum

Vue 3 - simple plug...
 
Notifications
Clear all

Vue 3 - simple plugin helper

1 Posty
1 Users
0 Reactions
610 Widok
0
Topic starter

how to write simple plugin

1 Answer
0
Topic starter

app.js

import DateHelpers from './helpers/DateHelpers'
...
app.use(DateHelpers);

inside DateHelpers.js

import moment from 'moment';
import 'moment/min/locales';

export default {
install: (app, options) => {
app.mixin({
methods: {
ago: function (date) {
return moment(date).fromNow();
},
},
})
},
};

now we can use ago() function inside our components

Odpowiedź

Author Name

Author Email

Your question *

 
Preview 0 Revisions Saved
Share: