docs: update icon doc
parent
1aa42dfe18
commit
d0ae9ccaeb
|
@ -80,25 +80,21 @@ See [iconfont.cn documents](http://iconfont.cn/help/detail?spm=a313x.7781069.199
|
||||||
|
|
||||||
### Custom SVG Icon
|
### Custom SVG Icon
|
||||||
|
|
||||||
You can import SVG icon as an react component by using `webpack` and [`@svgr/webpack`](https://www.npmjs.com/package/@svgr/webpack). `@svgr/webpack`'s `options` [reference](https://github.com/smooth-code/svgr#options).
|
You can import SVG icon as an vue component by using `vue cli 3` and [`vue-svg-loader`](https://www.npmjs.com/package/vue-svg-loader). `vue-svg-loader`'s `options` [reference](https://github.com/visualfanatic/vue-svg-loader).
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// webpack.config.js
|
// vue.config.js
|
||||||
{
|
module.exports = {
|
||||||
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
|
chainWebpack: (config) => {
|
||||||
use: [
|
const svgRule = config.module.rule('svg');
|
||||||
{
|
|
||||||
loader: 'babel-loader',
|
svgRule.uses.clear();
|
||||||
},
|
|
||||||
{
|
svgRule
|
||||||
loader: '@svgr/webpack',
|
.use('vue-svg-loader')
|
||||||
options: {
|
.loader('vue-svg-loader');
|
||||||
babel: false,
|
},
|
||||||
icon: true,
|
};
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
|
|
|
@ -78,25 +78,21 @@ new Vue({
|
||||||
|
|
||||||
### 自定义 SVG 图标
|
### 自定义 SVG 图标
|
||||||
|
|
||||||
如果使用 `webpack`,可以通过配置 [@svgr/webpack](https://www.npmjs.com/package/@svgr/webpack) 来将 `svg` 图标作为 `React` 组件导入。`@svgr/webpack` 的 `options` 选项请参阅 [svgr文档](https://github.com/smooth-code/svgr#options)。
|
如果使用 `vue cli 3`,可以通过配置 [vue-svg-loader](https://www.npmjs.com/package/vue-svg-loader) 来将 `svg` 图标作为 `Vue` 组件导入。更多`vue-svg-loader` 的使用方式请参阅 [文档](https://github.com/visualfanatic/vue-svg-loader)。
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// webpack.config.js
|
// vue.config.js
|
||||||
{
|
module.exports = {
|
||||||
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
|
chainWebpack: (config) => {
|
||||||
use: [
|
const svgRule = config.module.rule('svg');
|
||||||
{
|
|
||||||
loader: 'babel-loader',
|
svgRule.uses.clear();
|
||||||
},
|
|
||||||
{
|
svgRule
|
||||||
loader: '@svgr/webpack',
|
.use('vue-svg-loader')
|
||||||
options: {
|
.loader('vue-svg-loader');
|
||||||
babel: false,
|
},
|
||||||
icon: true,
|
};
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```jsx
|
```jsx
|
||||||
|
@ -105,8 +101,10 @@ import MessageSvg from 'path/to/message.svg'; // path to your '*.svg' file.
|
||||||
new Vue({
|
new Vue({
|
||||||
el: '#app',
|
el: '#app',
|
||||||
template: '<a-icon :component="MessageSvg" />',
|
template: '<a-icon :component="MessageSvg" />',
|
||||||
components: {
|
data() {
|
||||||
'my-icon': MyIcon,
|
return {
|
||||||
|
MessageSvg
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
|
@ -106,7 +106,6 @@
|
||||||
"eslint-plugin-html": "^3.2.2",
|
"eslint-plugin-html": "^3.2.2",
|
||||||
"eslint-plugin-vue": "^3.13.0",
|
"eslint-plugin-vue": "^3.13.0",
|
||||||
"eslint-plugin-vue-libs": "^1.2.1",
|
"eslint-plugin-vue-libs": "^1.2.1",
|
||||||
"extract-text-webpack-plugin": "^3.0.2",
|
|
||||||
"fetch-jsonp": "^1.1.3",
|
"fetch-jsonp": "^1.1.3",
|
||||||
"fs-extra": "^7.0.0",
|
"fs-extra": "^7.0.0",
|
||||||
"glob": "^7.1.2",
|
"glob": "^7.1.2",
|
||||||
|
|
|
@ -16,12 +16,14 @@
|
||||||
<a-tooltip :title="codeExpand ? 'Hide Code' : 'Show Code'">
|
<a-tooltip :title="codeExpand ? 'Hide Code' : 'Show Code'">
|
||||||
<span class="code-expand-icon">
|
<span class="code-expand-icon">
|
||||||
<img
|
<img
|
||||||
|
width="16"
|
||||||
alt="expand code"
|
alt="expand code"
|
||||||
src="https://gw.alipayobjects.com/zos/rmsportal/wSAkBuJFbdxsosKKpqyq.svg"
|
src="https://gw.alipayobjects.com/zos/rmsportal/wSAkBuJFbdxsosKKpqyq.svg"
|
||||||
:class="codeExpand ? 'code-expand-icon-hide' : 'code-expand-icon-show'"
|
:class="codeExpand ? 'code-expand-icon-hide' : 'code-expand-icon-show'"
|
||||||
@click="handleCodeExpand"
|
@click="handleCodeExpand"
|
||||||
/>
|
/>
|
||||||
<img
|
<img
|
||||||
|
width="16"
|
||||||
alt="expand code"
|
alt="expand code"
|
||||||
src="https://gw.alipayobjects.com/zos/rmsportal/OpROPHYqWmrMDBFMZtKF.svg"
|
src="https://gw.alipayobjects.com/zos/rmsportal/OpROPHYqWmrMDBFMZtKF.svg"
|
||||||
:class="codeExpand ? 'code-expand-icon-show' : 'code-expand-icon-hide'"
|
:class="codeExpand ? 'code-expand-icon-show' : 'code-expand-icon-hide'"
|
||||||
|
|
Loading…
Reference in New Issue