【发布时间】:2022-11-04 20:58:31
【问题描述】:
我需要从 Vue3 中的 URL 获取选举 id,以便在稍后的调用中将其用作 axios 调用中的查询参数。我的网址是“http://localhost:8080/#/requestPIN/py6lzerjwjntl4dmr9n77e6x73blk925?electionId=thirdElection”
我正在尝试做:
get ID(): string | undefined {
return this.$route.query.electionId
}
这给了我一个打字稿错误:
Type 'LocationQueryValue | LocationQueryValue[]' is not assignable to type 'string | undefined'. Type 'null' is not assignable to type 'string | undefined'.
URL 查询参数的正确类型是什么?
【问题讨论】:
标签: typescript url vuejs3 query-parameters typescript-eslint