When developing with vue3+ts, when configuring routing, the following problems occur:
When declaring routes by referring to RouteRecordRaw, an error is reported.
Solution:
the first method:
When importing, it is introduced in the form of type, and type is added in front:
import { createRouter, createWebHistory } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'
The second method:
Find the tsconfig.json file in the root directory , set preserveValueImports: false
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
},
"preserveValueImports": false
The above problem can be solved like this.