下面是浏览器有用,真机没用的;

import { getCurrentInstance ,computed} from 'vue';

const {proxy} = getCurrentInstance();

const router = computed(()=> proxy.$router.currentRoute.value.fullpath)
const metaName = computed(()=> proxy.$router.currentRoute.value..meta.navigationBar.titleText)
// 在chrome浏览器好使,真机报错,
import { useRouter } from "vue-router"
const route = useRouter()

//同上,浏览器好使,真机报错

下面是真机,好使,有用;

onMounted(()=>{
		//uniapp提供的方法,获取当前页面实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面
		const pagea = getCurrentPages();
		
		router.value = pagea[pagea.length-1].route;
		metaName.value = pagea[pagea.length-1].$page.meta.navigationBar.titleText;
		console.log(router.value ,metaName.value );
		
	})
Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐