简体   繁体   中英

How to use vue plugin in nuxt

There's a plugin called vue-chat-scroll and I would like to use it in nuxt. Am a beginner so I cant really understand how but I wonder if its possible to use this vue plugin in nuxt as plugin. how would one do that?

  1. Create a file inside plugins folder, for example, vue-chat-scroll.js with the following content:

     import Vue from 'vue' import VueChatScroll from 'vue-chat-scroll' Vue.use(VueChatScroll)
  2. In nuxt.config.js import the plugin as

     plugins: [...your existing plugins,'~/plugins/vue-chat-scroll.js']

and then follow the plugin tutorial for its API

Create a js file in plugin folder and name it vue-chat-scroll.js (the name is optional. It depends on you). then register your plugin inside this js file as follows:

import Vue from 'vue';
import VueChatScroll from 'vue-chat-scroll';

 Vue.component('VueChatScroll', VueChatScroll);

Then import it in nuxt.config.js inside plugins as follow:

plugins: [
  {
    src: '~/plugins/vue-chat-scroll.js',
    ssr: true
   }
]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM