iuer ui
iuer ui

Reputation: 117

using external component in Nuxt not working

I have component I install from npm

it called vue-3d-model

I create a file like this ~/plugins/ModelGltf.js

    import Vue from 'vue';
    import { ModelGltf } from 'vue-3d-model';

    Vue.use(ModelGltf)

and then I register it in nuxt.config.js

  plugins: [
    { src: '~/plugins/ModelGlft.js', ssr: false },
  ],

and I called in my component like <model-gltf> ........... but it was not rendering, in my console terminal it called Critical dependency: the request of a dependency is an expression and in my inspect it said <model-gltf> component is not register yet

I have been saw some question on stack overflow and tried their answers , still can't work

Upvotes: 0

Views: 2628

Answers (1)

Kenneth
Kenneth

Reputation: 2993

try to this,

in your ~/plugins/ModelGltf.js

import Vue from 'vue';
import { ModelGltf } from 'vue-3d-model';
Vue.component('ModelGltf', ModelGltf)

and then I register it in nuxt.config.js

{ src: '~/plugins/ModelGlft.js', ssr: false },

or

{ src: '@/plugins/ModelGlft.js', ssr: false },

Upvotes: 1

Related Questions