Al desarrollar con vue3+ts, al configurar el enrutamiento, ocurren los siguientes problemas:
Al declarar rutas haciendo referencia a RouteRecordRaw, se informa un error.
Solución:
el primer método:
Al importar, se introduce en forma de tipo, y el tipo se agrega al frente:
import { createRouter, createWebHistory } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'
El segundo método:
Busque el archivo tsconfig.json en el directorio raíz , configure preserveValueImports: false
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
},
"preserveValueImports": false
El problema anterior se puede resolver así.