javascript - Vue TypeScript ใช้ vue-property-decorator เพื่อแจ้งว่า router-view ยังไม่ได้ลงทะเบียน
<template>
<div id="app">
<router-view></router-view>
</div>
</template>
<script lang="ts">
import { Vue, Component } from 'vue-property-decorator'
@Component
export default class extends Vue {
}
</script>
ถ้าฉันรันโค้ดข้างต้น ฉันจะเจอข้อผิดพลาดหลังจากการรัน
Unknown custom element: <router-view> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
ถ้าฉันเอาออก
@Component
ฉันสามารถใช้มันได้ตามปกติไหม
ฉันจะใช้ @Component อย่างถูกต้องได้อย่างไร?
ฉันได้ลงทะเบียนเส้นทางของฉันใน main.ts แล้วเมื่อฉันลบ @Component ออก router-view ก็ยังมีผลอยู่
====
ใช้ในทุกหน้า
Import VueRouter from 'vue-router'
Vue.use(VueRouter)
นี่ได้ผล!