个人 UI 组件库
首页
core
vant2
element2
  • 分类
  • 标签
  • 归档
github (opens new window)
gitee (opens new window)

放肆青春

一个前端菜鸟的技术成长之路
首页
core
vant2
element2
  • 分类
  • 标签
  • 归档
github (opens new window)
gitee (opens new window)
  • 开发指南

    • 快速上手
  • 自定义组件

    • button
    • tabs
    • video
    • svg
      • 概述
      • 前置条件
      • 基础布局
        • 属性
  • core
放肆青春
2021-12-31

svg

# svg


# 概述

svg 组件

# 前置条件

  1. 1.安装 svg loader 依赖npm install svg-sprite-loader --save-dev

  2. 2.添加 loader 配置

 chainWebpack: (config) => {
    // svg是个基础loader
    const svgRule = config.module.rule("svg");

    // 清除已有的所有 loader。
    // 如果你不这样做,接下来的 loader 会附加在该规则现有的 loader 之后。
    svgRule.uses.clear();

    // 添加要替换的 loader
    svgRule
      .test(/\.svg$/)
      .include.add(resolve('src/icons')).end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .tap((options) => {
        // eslint-disable-next-line no-param-reassign
        options = {
          symbolId: 'icon-[name]',
        };
        return options;
      });
  },
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  1. 3.在使用 svg 的页面中导入 svg 图标

# 基础布局

<!-- svg组件 -->
<RzSvg iconClass="titile" iconStyle="width:100px;height:100px;" />
<script>
  // import "@/icons/svg/titile.svg";
  export default {
    data() {
      return {};
    },
    methods: {},
  };
</script>
1
2
3
4
5
6
7
8
9
10
11
Expand Copy Copy

# 属性

参数 说明 类型 可选值 默认值
iconClass svg 图标名称 string — -
iconStyle svg 图标样式 string — -
更新时间: 12/31/2021, 6:02:21 PM
video

← video

最近更新
01
快速上手
12-31
02
dialog
12-31
03
address
12-31
更多文章>
Theme by Vdoing | Copyright © 2019-2022 放肆青春
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式