vue中element-ui中的el-button自定义icon图标
warning:
这篇文章距离上次修改已过185天,其中的内容可能已经有所变动。
在Vue中使用Element UI的el-button
组件并自定义icon图标,可以通过以下两种方式实现:
- 使用Element UI提供的Icon组件:
<template>
<el-button type="primary" icon="el-icon-plus">按钮</el-button>
</template>
<script>
export default {
// 你的组件选项...
};
</script>
使用自定义的SVG图标:
首先,在你的组件中定义一个SVG图标,例如:
<template>
<el-button type="primary">
<!-- 这里插入你的自定义SVG图标 -->
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/><path d="M0 0h24v24H0z" fill="none"/></svg>
</el-button>
</template>
<script>
export default {
// 你的组件选项...
};
</script>
请确保你已经在项目中安装并引入了Element UI,并正确地全局或局部注册了el-button
和el-icon
组件。
评论已关闭