diff --git a/README.md b/README.md index 9ad9b1c..74e068e 100644 --- a/README.md +++ b/README.md @@ -145,8 +145,9 @@ import {createApp} from 'vue'; import VueFlatPickr from 'vue-flatpickr-component'; import 'flatpickr/dist/flatpickr.css'; // Your app initialization logic goes here -const app = createApp().mount('#app') +const app = createApp({}); app.use(VueFlatPickr); +app.mount('#app'); ``` This will register a global component `` diff --git a/src/component.js b/src/component.js index 78c4cfa..cd993f1 100644 --- a/src/component.js +++ b/src/component.js @@ -42,7 +42,7 @@ export default defineComponent({ ); } }, - // https://chmln.github.io/flatpickr/options/ + // https://flatpickr.js.org/options/ config: { type: Object, default: () => ({ @@ -59,14 +59,7 @@ export default defineComponent({ default: false } }, - data() { - return { - /** - * The flatpickr instance - */ - fp: null - }; - }, + fp: null, // non-reactive mounted() { // Return early if flatpickr is already loaded /* istanbul ignore if */ @@ -206,10 +199,9 @@ export default defineComponent({ }, beforeUnmount() { /* istanbul ignore else */ - if (this.fp) { - this.fpInput().removeEventListener('blur', this.onBlur); - this.fp.destroy(); - this.fp = null; - } + if (!this.fp) return + this.fpInput().removeEventListener('blur', this.onBlur); + this.fp.destroy(); + this.fp = null; } }); diff --git a/webpack.config.dev.js b/webpack.config.dev.js index 3fa2670..aab3342 100644 --- a/webpack.config.dev.js +++ b/webpack.config.dev.js @@ -106,7 +106,7 @@ module.exports = { }), new webpack.DefinePlugin({ __VUE_OPTIONS_API__: true, - __VUE_PROD_DEVTOOLS__: false + __VUE_PROD_DEVTOOLS__: true }), new VueLoaderPlugin(), ],