🔌 A simple Vue.js mixin for telling whether a component has been mounted.
With npm:
$ npm i vue-is-mounted
Or in the browser:
<script src="https://cdn.jsdelivr.net/npm/vue-is-mounted@1.0.0/index.min.js"></script>
const isMounted = require('vue-is-mounted');
new Vue({
// ...
mixins: [ isMounted ],
computed: {
foo() {
if (this.isMounted) {
console.log('bar');
}
}
}
});
new Vue({
// ...
mixins: [ window.vueIsMounted ], // window reference can be omitted
computed: {
foo() {
if (this.isMounted) {
console.log('bar');
}
}
}
});