This may be a really silly question, but nonetheless, something I can't find an answer to.
So, I am building up a Vue component and would like to access vue-spinner's component(s) inside of my component. How would I do that?
Here are snippets of the code in question:
app.js:
Vue.component('players', require('./components/TeamPlayersComponent.vue'));
import GridLoader from 'vue-spinner/src/GridLoader.vue';
const app = new Vue({
el: '#app',
components: {
GridLoader
}
});
TeamPlayersComponent.vue:
<grid-loader></grid-loader>
Assume that vue-spinner has been installed (NPM) and that the TeamPlayersComponent.vue
is valid and working other than giving this error in the console:
vue.js?3de6:525 [Vue warn]: Unknown custom element: <grid-loader> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
(found in component <players> at /home/vagrant/code/rounds-smaa/resources/assets/js/components/TeamPlayersComponent.vue)
I am using Vue with Laravel Elixir and Gulp.
You need to create your portfolio component first e.g. in src/components/Projects/Portfolio. vue and then import it inside the script tag within your Landing.
When we want to globally register a component in Vue, we need to do it in this file. All you have to do is import your component, as you usually would, and then register it using app. component . import { createApp } from 'vue' import App from './App.
There are a number of breaking changes from Vue 2 to 3. You won't be able to just use Vue 2 components in Vue 3 without accounting for these.
You can get it by following:
var PulseLoader = require('vue-spinner/src/PulseLoader.vue');
and add it in components:
new Vue({
components: {
'PulseLoader': PulseLoader
}
})
Solution:
Replace the GridLoader
specific code in app.js (Laravel setup) with:
Vue.component('grid-loader', require('vue-spinner/src/GridLoader.vue'));
Worked as expected!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With