As some of his comments mention, you can use the installed function. For more information, you can see this article: https://vuejsdevelopers.com/2017/05/20/vue-js-safely-jquery-plugin/
Here is a basic example of using cleave.js:
<template> <input /> </template> <script> import Cleave from 'cleave.js' export default { mounted () { new Cleave(this.$el, { date: true, datePattern: ['d', 'm', 'Y'] }) this.$el.oninput = (e) => { console.log('oninput the field', e.target.value) this.$emit('oninput', e.target.value) } } } </script> <style> </style>
App.vue
<template> <div id="app"> <smart-cleave @oninput="logIt"></smart-cleave> <div>{{date}}</div> </div> </template> <script> import Cleave from 'cleave.js' import SmartCleave from './components/SmartCleave' new Cleave('#plain-input', { date: true, datePattern: ['d', 'm', 'Y'] }) export default { name: 'app', components: { SmartCleave }, data () { return { date: '' } }, methods: { logIt (val) { console.log('cahnged', val) this.date = val } } } </script> <style> #app { font-family: 'Avenir', Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; color: #2c3e50; margin-top: 60px; } </style>
Daryn source share