vue动态设置页面title方法
第一种方法
npm install vue-wechat-title --save
- 在mian.js中引入
//设置title
import VueWechatTitle from 'vue-wechat-title'
Vue.use(VueWechatTitle)
- 在router的index.js的路由中加上参数
{
path: '/login',
component: Login,
meta: {
title: '登录'
}
}
- 如果是公共组件,在跳转时根据条件来动态设置title,可以在最外层的div上设置
v-wechat-title="$route.meta.title"再动态去改变title即可
<template>
<div class="hours-con container" v-wechat title="$route.meta.title">
.....
</div>
</template>
第二种方法
//在main.js中设置title
router.beforeEach((to, from, next) => {
/* 路由发生变化修改页面title */
if (to.meta.title) {
document.title = to.meta.title;
}
next();
})
vue动态设置页面title方法的更多相关文章
- 单页应用动态设置页面title
1.适用场景:所有通过router路由的单页应用. 2.示例代码:本文以vue-router为例. 在router.js中: let router = new Router({ routes: [ { ...
- 基于Vue的SPA动态修改页面title的方法
最近基于VUE做个SPA手机端web发现动态修改页面标题通过document.title=xxxx 来修改着实蛋疼,而且在IOS的微信端据说没效果.百度发现要针对IOS的微信做点额外的操作,即:创建一 ...
- 小程序之--动态设置页面标题 wx.setNavigationBarTitle
参考地址 http://www.yilingsj.com/xwzj/2018-11-26/weixin-navigationbartitletext.html 页面最初是[在线教研] 可以在这个页面的 ...
- VUE-CLI 设置页面title
router > index.js { path: '/worklist', name: 'worklist', component: worklist, meta: {title:'维修工列表 ...
- VUE修改每个页面title
//index.js routes: [ { name:'home', path: '/home/:openname', component: Home, meta: { title: '首页' } ...
- 每天一点点之vue框架开发 - 数据渲染-for循环中动态设置页面背景色
实现方式很简单,在属性前加:,表示绑定 :style="{'background':item.bgColor} 代码样例: <li v-for="item in laber_ ...
- (转)asp.net动态设置标题title 关键字keywords 描述descrtptions
方法一 if (!IsPostBack){//Page title网页标题Page.Title = “我的网站标题”;//须将网页head标签设成服务器控件模式,即<head runat=&qu ...
- Vue动态设置Dom元素宽高
需求: slider侧边栏是宽度是动态的,使用jquery可以操作dom元素,设置宽高,但vue是避免操作dom的 <template> <div class="slide ...
- vue动态切换页面
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
随机推荐
- SPOJ:Labyrinth(最大直线)
The northern part of the Pyramid contains a very large and complicated labyrinth. The labyrinth is d ...
- linux WEB服务器***
Apache sudo apt-get install apache2 PHP sudo apt-get install php5 sudo apt-get install php5-gd / ...
- list:[::5]
0-99的数列 L = [0, 1, 2, 3, ..., 99] 所有数,每5个取一个 >>> L[::5] [0, 5, 10, 15, 20, 25, 30, 35, 40, ...
- AWS EC2中部署Apache服务器(LAMP)
关键词: 1.新建aws ec2实例 2.使用putty连接到aws ec2 实例(SSH协议) 3.使用filezilla连接到aws ec2实例(SFTP协议) 4.在aws ec2上部署apac ...
- bzoj 3944: Sum【莫比乌斯函数+欧拉函数+杜教筛】
一道杜教筛的板子题. 两个都是积性函数,所以做法是一样的.以mu为例,设\( f(n)=\sum_{d|n}\mu(d) g(n)=\sum_{i=1}^{n}f(i) s(n)=\sum_{i=1} ...
- 洛谷P2221 [HAOI2012]高速公路(线段树+概率期望)
传送门 首先,答案等于$$ans=\sum_{i=l}^r\sum_{j=i}^r\frac{sum(i,j)}{C_{r-l+1}^2}$$ 也就是说所有情况的和除以总的情况数 因为这是一条链,我们 ...
- C# DateTime.Now 详解
//2008年4月24日 System.DateTime.Now.ToString("D"); //2008-4-24 System.DateTime.Now.ToString(& ...
- WCF、WebAPI、WebService之间的区别
Web Service 1.它是基于SOAP协议的,数据格式是XML 2.只支持HTTP协议 3.它不是开源的,但可以被任意一个了解XML的人使用 4.它只能部署在IIS上 WCF 1.这个也是基于S ...
- 第四篇(那些JAVA程序BUG中的常见单词)
xxx cannot be resolved to a variable xxx无法解析为变量 resolve 解析
- python数据库连接例子
import sqlite3 conn = sqlite3.connect('food.db') curs = conn.cursor() curs.execute(''' CREATE TABLE ...