关于vant:vant-引入icon-字体图标

Icon 组件默认援用有赞 CDN 提供的字体文件,并通过网络下载。如果须要在我的项目中应用本地字体文件,请引入上面的 CSS 文件,并在我的项目中配置 url-loader。

  1. 减少webpack.config.js配置
module.exports = function () {
  if (process.env.BUILD_TARGET === 'package') {
    return {};
  }

  return {
    entry: {
      'site-mobile': ['./docs/site/entry'],
      'site-desktop': ['./docs/site/entry'],
    },
    module:{
      rules:[
        {
          test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
          loader: 'url-loader',
          options: {
            limit: 10000,
            name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
          }
        }
      ]
    }
  };

 
};

UnhandledPromiseRejectionWarning: ReferenceError: utils is not defined
url-loader 装置版本过高,装置一个低版本的,有装置2.0.0,3.0.0都不行,最终抉择1.0.0

  1. 引入css文件
@import '../../packages/vant-icons/assets/iconfont/style.css';
  1. 批改style.css

设置font-family 和加前缀 van-icon
.van-icon-test:before {
content: “\e905”;
}

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理