vue模拟触发另一个按钮点击事件

2,016 阅读1分钟

vue.js

1,给另一个按钮添加ref

<el-button size="small" type="primary" ref="import">导入</el-button>

2,事件触发

this.$refs.import.$el.click()

jQuery

("#a").click(function(){ ("#b").trigger('click'); })

原生JS

document.getElementById('a').click();