这个报错只出现在安卓端,h5端没有出现
代码如下:
<script setup lang="ts">
import { useRoute } from 'vue-router'
const type = ref() // 获取路由参数中的 id
uni.setNavigationBarTitle({
title: type.value === 'yinsi' ? '隐私协议' : '服务协议'
})
onMounted(options => {
const route = useRoute()
console.log(route)
console.log(route.params.type)
})
</script>
报错如下
17:36:18.867 [Vue warn]: injection "Symbol(route location)" not found.
17:36:18.867 undefined at pages/yinsi/yinsi.vue:18
17:36:18.868 [Vue warn]: Unhandled error during execution of mounted hook
at <Yinsi__pageId=2__pagePath="pages/yinsi/yinsi"__pageQuery={"type":"fuwu"} ...>
17:36:18.868 TypeError: Cannot read property 'params' of undefined
1 个回复
hhyang - 如有问题,请添加QQ1606726660 备注付费咨询
vue-router 只支持h5端
如果你想是在跨端下使用,请选择 uni-app 的路由守卫 uni-simple-router