route.query拿到的参数如何做类型推断?-灵析社区

萌蒙萌

const route = useRoute() const { sceneId, entry, name, mode } = route.query 每个参数的类型为`string | string[]` 如何能统一改成`string`呢? 用`const sceneId = route.query.sceneId as string`可以实现,但是每个参数都得这样写一遍吗?

阅读量:197

点赞量:0

问AI
销售经理537
为什么会有这样的需求,像上面说了,万一这样不就爆了,程序还是严谨点会比较好