因為和原生的交互是需要h5這邊來提供meta標簽的來是來判斷要不要顯示分享按鈕,所有就需要手動設置meta標簽,標題和內容
//router內的設置
{
path: '/teachers',
name: 'TDetail',
component: TDetail,
meta: {
title:"教師詳情",
content: 'disable'
}
},
{
path: '/article',
name: 'Article',
component: Article,
meta: {
title: "文章詳情",
content: 'disable-no'
}
},
//main.js里面的代碼
router.beforeEach((to, from, next) => {
/* 路由發生變化修改頁面meta */
if(to.meta.content){
let head = document.getElementsByTagName('head');
let meta = document.createElement('meta');
meta.content = to.meta.content;
head[0].appendChild(meta)
}
/* 路由發生變化修改頁面title */
if (to.meta.title) {
document.title = to.meta.title;
}
next()
});
轉自:https://blog.csdn.net/qq_29515037/article/details/79475068
