vuejs / vue-class-component

ES / TypeScript decorator for class-style Vue components.
MIT License
5.81k stars 429 forks source link

The global component cannot be used #513

Closed foreverhot closed 3 years ago

foreverhot commented 3 years ago

error: image

// App.vue
<template>
  <div id="app">
    <router-view />
  </div>
</template>
<script lang="ts">
  import { Component, Vue } from 'vue-property-decorator'

  @Component
  export default class App extends Vue {
    mounted() {
      console.log('this:', this)
      console.log('this.$route:', this.$route)
    }
  }
</script>
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import Elementui from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

Vue.config.productionTip = false

Vue.use(Elementui)

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')

Not only that, but global UI components are also unavailable

Unknown custom element: <el-button> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
Giwayume commented 3 years ago

Can you upload your package.json?

Also I don't see this line, which is required for Webpack applications:

Vue.use(VueRouter);
foreverhot commented 3 years ago

thanks ,I've found the problem. It's a Webpack configuration problem