错误:Cannot read properties of undefined (reading 'component')
我正在工作 vue.js3 + laravel8
我正在尝试将我重用的 my-button 组件注册为全局组件
vue.js3 + lorevel8
我的 app.js
window.Vue = require('vue').default;
import { createApp } from 'vue';
import router from "./router";
import components from './components/UI'
components.forEach(component => {
app.component(component.name, component)
})
const app = createApp({})
app.use(router)
.mount("#app")
我的 Index.js
import MyButton from "./MyButton";
export default [
MyButton
]
我的按钮.vue
<template>
<button class="btn">
<slot></slot>
</button>
</template>
<script>
export default {
name: "my-button"
}
</script>
<style scoped lang="scss">
.btn {
background-color: var(--color-primary-light);
color: #fff;
border: none;
border-radius: 0;
font-family:'Josefin Sans', sans-serif;
font-size: 1.5rem;
text-transform: uppercase;
padding: 1.8rem 3rem;
cursor: pointer;
transition: all .2s;
&:hover {
background-color: var( --color-primary-dark);
}
}
</style>
错误:无法读取未定义的属性(读取“组件”)
有人可以帮我吗?
无法弄清楚 undefined 的属性