尝试在 vuejs3 应用程序中使用 vue-select 我在控制台中遇到错误:
test.vue?2762:16 Uncaught TypeError: _App_vue__WEBPACK_IMPORTED_MODULE_2__.default.component is not a function
at eval (test.vue?2762:16)
at Module../node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader-v16/dist/index.js?!./src/views/test.vue?vue&type=script&lang=js (app.js:1079)
at __webpack_require__ (app.js:854)
at fn (app.js:151)
at eval (test.vue?c371:1)
at Module../src/views/test.vue?vue&type=script&lang=js (app.js:1613)
at __webpack_require__ (app.js:854)
at fn (app.js:151)
at eval (test.vue?b424:1)
at Module../src/views/test.vue (app.js:1601)
我的vue文件:
<template>
<div>
<h1>Vue Select</h1>
stringVar:{{ stringVar}}
<v-select :options="options"></v-select>
</div>
</template>
<script>
import app from './../App.vue'
import { ref, onMounted } from 'vue'
import vSelect from 'vue-select'
import 'vue-select/src/scss/vue-select.scss'
app.component('v-select', vSelect)
export default {
name: 'loginPage',
components: {},
setup () {
let stringVar = ref('Init value')
const options = [
{
code: 'A',
label: 'Active'
},
{
code: 'I',
label: 'Inactive'
},
{
code: 'N',
label: 'New'
}
]
const testInit = async () => {
console.log('testInit emitter::')
}
onMounted(testInit)
return {
stringVar
}
} // setup () {
}
</script>
在 package.json 中:
"vue": "^3.0.0",
"vue-select": "^3.10.8",
我是否以错误的方式配置了 vue-select 或者 vue-select 不适用于 vuejs 3?在这里https://github.com/sagalbot/vue-select我没有找到任何提及 vuejs 3,但最后一次源更新是 3 个月前...
谢谢!