Home

Awesome

vue-svg-icon

a solution for multicolor svg icons in vue2 轻量的Vue2多色动态svg图标方案 中文版说明

v1.2.9

demo: https://cenkai88.github.io/vue-svg-icon/demo/
features:

Usage

1. install

npm install vue-svg-icon --save-dev

2. put your svg into src/svg/

3. import vue-svg-icon in your main.js

import Icon from 'vue-svg-icon/Icon.vue';
Vue.component('icon', Icon);  

4. use the svg icon in your vue!

<icon name="chameleon" :scale="20"></icon>

Edit svg pictures in illustrator

Trouble Shooting

  1. cannot find corresponding .svg file in vue-svg-icon/svg when you inject it in main.js, please keep the name in main.js and the filename exactly same.
[Vue warn]: Invalid prop: custom validator check failed for prop "name". 
  1. cannot find the "svg" fold in src folder
This dependency was not found:
   
   * !xml-loader!../../src/svg in ./~/.6.4.1@babel-loader/lib!./~/.11.1.4@vue-loader/lib/selector.js?type=script&index=0!./~/.1.2.8@vue-svg-icon/Icon.vue
   
   To install it, you can run: npm install --save !xml-loader!../../src/svg
  1. pls check the .babelrc file of root folder
Module build failed: ReferenceError: Unknown plugin "transform-runtime"
 specified in "/Users/test/Desktop/Dev/github/.babelrc" at 0, attempted to resolve relative to 
 "/Users/test/Desktop/Dev/github"

中文版本说明

示例: https://cenkai88.github.io/vue-svg-icon/demo/   特点:

1. 安装

npm install vue-svg-icon --save-dev

2. 将svg图片放入src/svg/

这里安利一个svg图片库iconfont

3. 在项目的main.js入口引入vue-svg-icon

import Icon from 'vue-svg-icon/Icon.vue';
Vue.component('icon', Icon); 

4. 在网页中使用icon标签就可以啦!

<icon name="chameleon" scale="20"></icon>

在illustrator中编辑svg图片时

For detailed explanation on how things work, checkout the guide and docs for vue-loader.