3

I have a fresh Vue 3 installed with vue-cli and typescript. Everything running but when I add a https://vue-select.org/ package I get get this error on the browser console

Uncaught (in promise) TypeError: this.$on is not a function
    at Proxy.created (vue-select.js?4a7a:1)
    at callWithErrorHandling (runtime-core.esm-bundler.js?5c40:155)
    at callWithAsyncErrorHandling (runtime-core.esm-bundler.js?5c40:164)
    at callHook (runtime-core.esm-bundler.js?5c40:3182)
    at applyOptions (runtime-core.esm-bundler.js?5c40:3109)
    at finishComponentSetup (runtime-core.esm-bundler.js?5c40:7265)
    at setupStatefulComponent (runtime-core.esm-bundler.js?5c40:7190)
    at setupComponent (runtime-core.esm-bundler.js?5c40:7117)
    at mountComponent (runtime-core.esm-bundler.js?5c40:5115)
    at processComponent (runtime-core.esm-bundler.js?5c40:5090)

Simple example

Home.vue
<template>
  <div class="home">
    <img alt="Vue logo" src="../assets/logo.png">
    <vSelect :options="[{label: 'Canada', code: 'ca'}]"></vSelect>
  </div>
</template>

<script lang="ts">
import { Options, Vue } from 'vue-class-component';
import HelloWorld from '@/components/HelloWorld.vue'; // @ is an alias to /src
import vSelect from 'vue-select';

@Options({
  components: {
    HelloWorld,
    vSelect
  },
})
export default class Home extends Vue {}
</script>


Rolly
  • 3,205
  • 3
  • 26
  • 35
  • 1
    it looks like this component doesn't support vue 3 – Boussadjra Brahim Jul 05 '21 at 22:00
  • @Boussadjra is right, you can follow the [open ticket](https://github.com/sagalbot/vue-select/issues/1251) on github. Here is an alternative [vue next select](https://iendeavor.github.io/vue-next-select/) that was written in the comments. – wittgenstein Jul 06 '21 at 00:02

1 Answers1

-1

I think the problem is not related to Vue3. It is related to typescript. Just add this package @types/vue-select. This package contains type definitions for vue-select. Also if you are using webpack for your bundler, don't forget to add this package @types/webpack-env. It contains type definitions for webpack.

Buddy1234
  • 9
  • 2