======================================vue
适用于web
1.微信 2.webview 3.各大浏览器 --------
demo: http://www.yahoo.com/npm
首先执行命令浏览器
vue2.x用法 npm install vue-wechat-title;
以后在main.js全局入口处,引入wechat-title微信
Vue.use(require('vue-wechat-title'));
而后在router路由中ui
export default new Router({ routes: [ { path: '/', redirect: 'index', }, { path: '/index', name: 'Index', component: Index, meta: { title: '首页' }, }, { path: '/project', name: 'Project', component: Project, meta: { title: '活动项目' }, }, { path: '/service', name: 'Service', component: Service, meta: { title: '服务' }, }, { path: '/interspace', name: 'Interspace', component: Interspace, meta: { title: '空间' }, }, { path: '/discover', name: 'Discover', component: Discover, meta: { title: '发现' }, }, { path: '/my', name: 'My', component: My, meta: { title: '个人' }, }, ]} )
以后在各个组建中随便一个标签中均可写入spa
<div v-wechat-title="$route.meta.title"></div> or/ <router-view v-wechat-title="$route.meta.title"></router-view>
想要动态的改变title值,能够这样写code
<div v-wechat-title="$route.meta.title={data.title}"></div>