vue的el-button防止重复点击

这样效果仅生效在按钮上

### 使用方法 在 Vue 项目中使用 `el-button` 组件,首先要确保已经安装了 ElementUI 库。以下是一些使用示例: #### 基础使用 ```vue <template> <div> <el-button>默认按钮</el-button> <el-button type="primary">主要按钮</el-button> <el-button type="success">成功按钮</el-button> <el-button type="info">信息按钮</el-button> <el-button type="warning">警告按钮</el-button> <el-button type="danger">危险按钮</el-button> </div> </template> <script> export default { // 组件逻辑 }; </script> ``` #### 按钮组封装使用 ```vue <template> <div> <el-button-group> <el-button v-for="item in btns" :key="item.name" :type="item.type ? (item.type === 'default' ? '' : item.type) : 'primary'"> {{ item.name }} </el-button> </el-button-group> </div> </template> <script> export default { data() { return { btns: [ { // 按钮名称 name: "歌谣", // 按钮类型 type: "primary" }, { name: "歌谣1", type: "default" }, { name: "歌谣2", type: "primary" }, { name: "歌谣3", type: "default" } ] }; } }; </script> ``` #### 模拟点击事件 ```vue <template> <div> <el-button ref="myButton" @click="handleClick">点击我</el-button> <el-button @click="simulateClick">模拟点击</el-button> </div> </template> <script> export default { methods: { handleClick() { console.log('按钮被点击了'); }, simulateClick() { this.$refs.myButton.$el.click(); } } }; </script> ``` ### 功能特性 - **多种类型**:提供了 `primary`、`success`、`info`、`warning`、`danger`、`default` 等多种类型的按钮,以满足不同的视觉和业务需求。 - **按钮组**:可以使用 `el-button-group` 组件将多个按钮组合在一起,形成按钮组,增强视觉效果和交互性。 - **事件绑定**:支持常见的事件绑定,如 `click` 事件,方便实现各种交互逻辑。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值