What would be the steps to add a component to Vite with Vue, as an npm package?
I assumed these:
npm install example
- open
src/App.vue
and addimport Example from 'example'
- in
App.vue
, in<template>
, add<Example />
Is that correct?
I am trying to install and use vue-select
like so, but it's not working:
Your screenshot shows you're importing
vSelect
in a<script>
block, and expecting it to be automatically registered for the component's template. That would only work in a<script setup>
block.However, your GitHub repo (which seems to be different from the screenshot you posted) reveals other issues in your code:
v-select
component in your Vue 3 app. In Vue 3, global component registration is done from the application instance (i.e., returned fromcreateApp()
).@import
(CSS syntax) to import your SCSS file in the<script>
block. Either move the CSS into a<style lang="scss">
block; or remove the@
prefix, which would create a validimport
for<script>
.sass
, which is required to process SCSS files. You can install it as a dev dependency with:Here's a demo with the fixes pointed out above.