3

Hi i could you please help me to convert this into javascript in Vue3 thank you

import type { App } from 'vue'
import Screenfull from './Screenfull.vue'

const components = [
  Screenfull,
]

const install = (app: App): void => {
  components.forEach(component => {
    app.component(component.name, component)
  })
}

export default install
0

1 Answer 1

3

Your plugin loops through a bunch of components and registers them globally, using the name property of the component. So make sure each component registered this way has a name property:

Dashboard.vue

<template>
  <div>My component</div>
</template>
export default {
  name: 'Dashboard'      // ✅ Add this
}

Remove the typing from the install function:

const install = (app) => {
  components.forEach(component => {
    app.component(component.name, component)
  })
}

Remove this line:

import type { App } from 'vue'
Sign up to request clarification or add additional context in comments.

Comments