Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Latest commit

 

History

History
56 lines (43 loc) · 757 Bytes

README.md

File metadata and controls

56 lines (43 loc) · 757 Bytes

vue-is-mounted

🔌 A simple Vue.js mixin for telling whether a component has been mounted.

Install

With npm:

$ npm i vue-is-mounted

Or in the browser:

<script src="https://cdn.jsdelivr.net/npm/[email protected]/index.min.js"></script>

Usage

Node.JS

const isMounted = require('vue-is-mounted');

new Vue({
  // ...
  mixins: [ isMounted ],
  computed: {
    foo() {
      if (this.isMounted) {
        console.log('bar');
      }
    }
  }
});

Browser

new Vue({
  // ...
  mixins: [ window.vueIsMounted ], // window reference can be omitted
  computed: {
    foo() {
      if (this.isMounted) {
        console.log('bar');
      }
    }
  }
});

License

MIT