Nuxt 3 export default class and how to use it

Viewed 315

i am testing nuxt 3 with plugins class and i was doing it like this.

index.js

class Basic {
  constructor(_options) {
    console.log('basic here')
  }

  getName(_name) {
    console.log(_name)
  }
}

export default new Basic

so i have a few question here. 1.how do i use this class in one of the component or file as nuxt 3 already automatic import it and i dont need to call it out using new Basic like before.

2.how do i pass the parameter into constructor as it already create the new Basic with in the same file.

here is my sample : https://stackblitz.com/edit/nuxt-starter-5ggqo1?file=pages%2Findex.vue

0 Answers
Related