你懂我意思吧
你懂我意思吧
  • 发布:2023-11-10 17:41
  • 更新:2023-12-24 13:51
  • 阅读:460

[报bug] 用vue3+ts开发安卓app,vue-router报错,injection "Symbol(route location)" not found.

分类:uni-app

这个报错只出现在安卓端,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
2023-11-10 17:41 负责人:无 分享
已邀请:
hhyang

hhyang - 如有问题,请添加QQ1606726660 备注付费咨询

vue-router 只支持h5端

如果你想是在跨端下使用,请选择 uni-app 的路由守卫 uni-simple-router

要回复问题请先登录注册