Open seepine opened 7 months ago
vite.config.js
import Components from 'unplugin-vue-components/vite' export default defineConfig({ plugins: [ uni(), Components({ dirs: ['src/components'] }) ] })
tsconfig.json
{ "extends": "@vue/tsconfig/tsconfig.json", "compilerOptions": { "sourceMap": true, "baseUrl": ".", "paths": { "@/*": ["./src/*"] }, "lib": ["esnext", "dom"], "ignoreDeprecations": "5.0" }, "include": [ "src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue", "*.d.ts" ] }
components.d.ts
/* eslint-disable */ /* prettier-ignore */ // @ts-nocheck // Generated by unplugin-vue-components // Read more: https://github.com/vuejs/core/pull/3399 export {} declare module 'vue' { export interface GlobalComponents { MyNav: typeof import('./src/components/my-nav/my-nav.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] } }
my-nav.vue
<template> <view class="bg-sky-500"> my-nav </view> </template>
效果图
直接使用,没有提示
手动引用,才有提示
可以使用vite-plugin-uni-components代替,来解决这个问题
vite.config.js
tsconfig.json
components.d.ts
my-nav.vue
效果图
直接使用,没有提示
手动引用,才有提示