尝试在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我没有发现任何关于Vuejs3的提及,但最后一次源码更新是在3个月前……
谢谢!
发布于 2020-11-13 01:38:32
我想图书馆还没有更新。在他们的package.json中,它说他们仍然依赖于:"vue": "^2.6.10"。也许你应该在他们的github项目上打开一个问题?
https://stackoverflow.com/questions/64782489
复制相似问题