Typescript Vue上不存在Nuxt$路由
嘿嘿, 我有个奇怪的问题。我有一个带有Typescript的Nuxt应用程序。在Typescript Vue上不存在Nuxt$路由,typescript,vue.js,nuxt.js,Typescript,Vue.js,Nuxt.js,嘿嘿, 我有个奇怪的问题。我有一个带有Typescript的Nuxt应用程序。在创建的钩子I控制台中.log此.$route。这个日志确实有用。以及读取路线上的参数 但我在构建应用程序时在控制台中遇到一个错误: 属性$route在类型SomeClass上不存在 这是我的班级: 从“Vue”导入Vue 从“vue类组件”导入组件 @组成部分 导出默认类SomeClass扩展Vue{ 公共id!:字符串 创建(){ console.log('this:',this) this.id=this.$ro
创建的钩子I控制台中.log
此.$route
。这个日志确实有用。以及读取路线上的参数
但我在构建应用程序时在控制台中遇到一个错误:
属性$route
在类型SomeClass
上不存在
这是我的班级:
从“Vue”导入Vue
从“vue类组件”导入组件
@组成部分
导出默认类SomeClass扩展Vue{
公共id!:字符串
创建(){
console.log('this:',this)
this.id=this.$route.params.id
}
}
console.log
工作正常,并通过其参数显示正确的路由。
我怎样才能消除这个错误
这是我的tsconfig.json
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"lib": [
"esnext",
"esnext.asynciterable",
"dom"
],
"esModuleInterop": true,
"experimentalDecorators": true,
"skipLibCheck": true,
"allowJs": true,
"sourceMap": true,
"strict": true,
"noImplicitAny": false,
"noEmit": true,
"baseUrl": ".",
"paths": {
"~/*": [
"./*"
],
"@/*": [
"./*"
]
},
"types": [
"@types/node",
"@nuxt/vue-app",
"element-ui/types"
]
}
}
好的,多亏了@aBiscuit,我才得到它。tsconfig中缺少类型定义。
在“类型”下只需添加@numxt/types
这是我正在工作的新配置
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"lib": [
"esnext",
"esnext.asynciterable",
"dom"
],
"esModuleInterop": true,
"experimentalDecorators": true,
"skipLibCheck": true,
"allowJs": true,
"sourceMap": true,
"strict": true,
"noImplicitAny": false,
"noEmit": true,
"baseUrl": ".",
"paths": {
"~/*": [
"./*"
],
"@/*": [
"./*"
]
},
"types": [
"@types/node",
"@nuxt/vue-app",
"element-ui/types"
]
}
}
好的,多亏了@aBiscuit,我才得到它。tsconfig中缺少类型定义。
在“类型”下只需添加@numxt/types
这是我正在工作的新配置
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"lib": [
"esnext",
"esnext.asynciterable",
"dom"
],
"esModuleInterop": true,
"experimentalDecorators": true,
"skipLibCheck": true,
"allowJs": true,
"sourceMap": true,
"strict": true,
"noImplicitAny": false,
"noEmit": true,
"baseUrl": ".",
"paths": {
"~/*": [
"./*"
],
"@/*": [
"./*"
]
},
"types": [
"@types/node",
"@nuxt/vue-app",
"element-ui/types"
]
}
}
可能是typescript配置问题或缺少/无效定义。请添加您的tsconfig.json
,或者如果可能,提供一个复制repo。Hi@aBiscuit我确实添加了我的tsconfig。这可能是typescript配置问题或缺少/无效的定义。请添加您的tsconfig.json
,或者如果可能的话提供一份复制报告。嗨@aBiscuit我确实添加了我的tsconfig。