// src/ui/tabbar/Index.vue
<template>
<div>
my-tabbar
</div>
</template>
// src/ui/index.js
import MyTabbar from './tabbar/Index.vue'
export default {
install(Vue) {
Vue.component(MyTabbar.name, MyTabbar)
}
}
// src/main.js
import Vue from 'vue'
import App from './App.vue'
Vue.config.productionTip = false
Vue.use(ui)
new Vue({
render: (h) => h(App)
}).$mount('#app')
// src/App.vue
<template>
// [ctrl + click] my-tabbar tips no definition found for 'my-tabbar'
<my-tabbar>/<my-tabbar>
</template>
vscode [ctrl+click]‘vue 单文件组件’,‘转到定义’不起作用
如何通过 [ctrl + click] 跳转到 'src/ui/tabbar/Index.vue'
可以把它添加到项目的 nuxt.config.ts 中:
export default defineNuxtConfig({
components: [
{
path: '~/components',
pathPrefix: false,
}
]
})
现在无需手动导入,也无需 前缀,仅需 和 ctrl+click 即可正常工作。