vue2修改浏览器显示title

一、配置路由器的时候添加如下项 meta routes: [ { path: '/', name: 'login', component: Login, meta: { title: '登录' } }, { path: '/home', name: 'home', component: Home, meta: { title: '首页' } } ]二、在main.js中写全局路由钩子 // 路由钩子router.beforeEach((to, from, next) => { if (to.meta.title) { document.title = to.meta.title } next()})这样就可以在路由跳转的时候修改响应界面的title值了。

August 28, 2019 · 1 min · jiezi

为VUE 脚手架中自定义title标签页小图标

效果如图所示:一、 在项目index.html同级目录下添加favicon.ico文件二、 在项目index.html中引入<link rel=“shortcut icon” type=“image/x-icon” href="./favicon.ico" />三、 配置webpack配置文件(build文件夹下面)在下面两个配置文件中加入:favicon: path.resolve(’./favicon.ico’)具体位置:1.webpack.prod.conf.js new HtmlWebpackPlugin({ filename: config.build.index, template: ‘index.html’, favicon: path.resolve(’./favicon.ico’), inject: true, }), 2. webpack.prod.dev.jsnew HtmlWebpackPlugin({ filename: process.env.NODE_ENV === ’testing’ ? ‘index.html’ : config.build.index, template: ‘index.html’, favicon: path.resolve(’./favicon.ico’), inject: true, minify: { removeComments: true, collapseWhitespace: true, removeAttributeQuotes: true // more options: // https://github.com/kangax/html-minifier#options-quick-reference }

April 17, 2019 · 1 min · jiezi