vue-rangedate-picker icon indicating copy to clipboard operation
vue-rangedate-picker copied to clipboard

I'm getting did you register the component correctly? error while trying to use vue-rangedate-picker component

Open zeuyanik opened this issue 6 years ago • 5 comments

Hi everyone, I followed the instruction on the https://bliblidotcom.github.io/vue-rangedate-picker/

but. code gives me the following error;

Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.

My vue code is the following;

<template>
    <vue-rangedate-picker ></vue-rangedate-picker>
</template>

<script>
    import Vue from 'vue';
    import VueRangedatePicker from 'vue-rangedate-picker';

    Vue.use(VueRangedatePicker);
</script>

What am I missing?

zeuyanik avatar Jun 04 '18 07:06 zeuyanik

@zeuyanik I also had the same problem. You will not be able to register the plugin globally since it is not exporting a vue package. I had to import locally into each component in order to work.

lucascardial avatar Jun 08 '18 16:06 lucascardial

@zeuyanik @lucca-cardial Try to register it manually like this

import Vue from 'vue';
import DateRangePicker from 'vue-rangedate-picker';

Vue.component('vuejs-daterangepicker', DateRangePicker);

new Vue({
  ...
});

You can change 'vuejs-daterangepicker' with whatever name you want. Notice that Vue.component method should be called before new Vue.

bondansebastian avatar Jun 27 '18 06:06 bondansebastian

@bondansebastian thanks. works great. Seems like something that should be documented? @bliblidotcom?

Pyro979 avatar Feb 20 '19 20:02 Pyro979

@bondansebastian -- The critical information for me was the simple but cogent advice:

Notice that Vue.component method should be called before new Vue.

That was the reason for my getting the error message. Thanks.

i-am-al-x avatar Sep 09 '19 17:09 i-am-al-x

This worked in my case.

Create a config folder right where main.js is.

In that folder create setup-component.js file.

import WHAT from '../where/notsurewhere';
 function setupComponents(Vue) {
	Vue.component('what', WHAT);
 }

 export { setupComponents };
 // Note: Same as file

And at last, just import that in main.js import { setupComponents } from './config/setup-components'; A friend of mine suggested this.

Shinobi247 avatar Jul 02 '20 09:07 Shinobi247