让网站在浏览器网址前面显示小图标

方法一:比较麻烦,修改脚手架达到效果
效果图:这里写图片描述

项目是基于vue2.0的。

  1. 打开npm官网 https://www.npmjs.com
    搜索 favicons-webpack-plugin 插件

  2. 下载包

npm install --save-dev favicons-webpack-plugin
  1. 在webpack.dev.conf.js中添加
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
  1. plugins 数组中添加
plugins: [
  new FaviconsWebpackPlugin({
    // Your source logo 
    logo: './logo.png',
    // The prefix for all image files (might be a folder or a name) 
    prefix: 'icons-[hash]/',
    // Emit all stats of the generated icons 
    emitStats: false,
    // The name of the json containing all favicon information 
    statsFilename: 'iconstats-[hash].json',
    // Generate a cache file with control hashes and 
    // don't rebuild the favicons until those hashes change 
    persistentCache: true,
    // Inject the html into the html-webpack-plugin 
    inject: true,
    // favicon background color (see https://github.com/haydenbleasel/favicons#usage) 
    background: '#fff',
    // favicon app title (see https://github.com/haydenbleasel/favicons#usage) 
    title: 'Webpack App',

    // which icons should be generated (see https://github.com/haydenbleasel/favicons#usage) 
    icons: {
      android: true,
      appleIcon: true,
      appleStartup: true,
      coast: false,
      favicons: true,
      firefox: true,
      opengraph: false,
      twitter: false,
      yandex: false,
      windows: false
    }
  })
]

index.html 和 logo.png的位置
这里写图片描述

  • 方法二:( 建议使用 .ico的后缀名 )
//index.html
<link rel="icon" sizes="48x48" href="/favicon.png">

这个方法就是这么简单的~~~~

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值