router.beforeEach里
//多語言項(xiàng)目,根根據(jù)自己項(xiàng)目來 import i18n from \’@/i18n/index\’; document.title = i18n.t(\”router.\” to.name) //單語言項(xiàng)目 document.title = to.name
語言切換路由不變,所以也要加一下,單語言項(xiàng)目不用
//多語言項(xiàng)目 document.title = i18n.t(\”router.\” to.name)
完活,推薦使用,原生兼容性好,不用下載安裝其他依賴包
第二種
使用插件
1.安裝插件
npm install vue-wechat-title –save
2.main.js 引用
import VueWechatTitle from \’vue-wechat-title\’//動(dòng)態(tài)修改titleVue.use(VueWechatTitle)
3.添加指令
//多語言項(xiàng)目 <router-view v-wechat-title=\”$t(\’router.\’ $route.name)\” ></router-view> //單語言項(xiàng)目 <router-view v-wechat-title=\” $route.name\” ></router-view>
完活
筆記
注意:值根據(jù)自己項(xiàng)目路由結(jié)構(gòu)來,本demo用的是name值,i18n有對應(yīng)語言包, 你可以在meta對象里加個(gè)title屬性,在外面用to.meta.title即可
更多關(guān)于云服務(wù)器,域名注冊,虛擬主機(jī)的問題,請?jiān)L問西部數(shù)碼官網(wǎng):m.ps-sw.cn