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

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 );
		
	})
GitHub 加速计划 / vu / vue
207.52 K
33.66 K
下载
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
最近提交(Master分支:1 个月前 )
73486cb5 * chore: fix link broken Signed-off-by: snoppy <michaleli@foxmail.com> * Update packages/template-compiler/README.md [skip ci] --------- Signed-off-by: snoppy <michaleli@foxmail.com> Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com> 3 个月前
e428d891 Updated Browser Compatibility reference. The previous currently returns HTTP 404. 3 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐