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

12次阅读

共计 685 个字符,预计需要花费 2 分钟才能阅读完成。

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”;
}

正文完
 0