невозможно добавить npm пакет в nuxt js [vue -star-rating] - PullRequest
0 голосов
/ 18 марта 2020

Я новичок в nuxt js, поэтому, когда я пытаюсь добавить npm пакетов, это не сработает, это испытания.

звездный дождь. js

import Vue from 'vue'
import StarsRatings from 'vue-star-rating'
Vue.use(StarsRatings)

nuxt.config. js

    plugins: [{ src: '~/plugins/star-rating.js', mode: 'client' }],
    build: {
    /*
     ** You can extend webpack config here
     */
    extend(config, ctx) {},
    transpile: ['star-rating']
  }

показывает эти ошибки

[Vue warn]: The client-side rendered virtual DOM tree is not matching server-rendered content. This 
is likely caused by incorrect HTML markup, for example nesting block-level elements inside <p>, or 
missing <tbody>. Bailing hydration and performing full client-side render.


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

found in

---> <Deals> at components/Home/Deals.vue
<Home> at pages/index.vue
<Nuxt>
<Default> at layouts/default.vue
<Root>

1 Ответ

1 голос
/ 18 марта 2020

Вы должны зарегистрировать его в своем звездном рейтинге. js следующим образом:

import Vue from 'vue';
import StarsRatings from 'vue-star-rating';

Vue.component('StarsRatings', StarsRatings);
...