无法将npm软件包添加到nuxt js [vue-star-rating]

问题描述 投票:0回答:1

我是nuxt js的新手,因此,当我尝试添加npm软件包时,这些是不可行的,这些是试验。

star-raing.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']
  }

it shows these errors

[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>

我是nuxt js的新手,因此,当我尝试添加npm软件包时,这些方法将无法正常工作。 star-raing.js从“ vue”导入Vue从“ vue-star-rating”导入StarsRatings Vue.use(StarsRatings)nuxt.config ....

javascript vue.js npm plugins nuxt.js
1个回答
0
投票

您应按如下所示在star-rating.js中注册它:

© www.soinside.com 2019 - 2024. All rights reserved.