Pattern: Use of deprecated events API
Issue: -
This rule reports use of deprecated $on
, $off
$once
API. (in Vue.js 3.0.0+).
<script>
/* ✗ BAD */
export default {
mounted () {
this.$on('start', function(args) {
console.log('start')
})
this.$emit('start')
}
}
</script>
<script>
/* ✓ GOOD */
import mitt from 'mitt'
const emitter = mitt()
export default {
mounted () {
emitter.on('start', function(args) {
console.log('start')
})
emitter.emit('start')
}
}
</script>