JSFiddle - React, Tailwind, and code Playground
HTML
<script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/element-ui/lib/index.js"></script>
<div id="app">
<el-input v-model="input" placeholder="请输入内容" ref="input1"></el-input>
<el-button @click="focus">获取焦点</el-button>
</div>
SCSS
@import url("//unpkg.com/element-ui/lib/theme-default/index.css");
.el-button {
margin-top: 20px;
}
Babel + JSX
var Main = {
data() {
return {
input: ''
}
},
methods: {
focus() {
this.$refs.input.$el.querySelector('input').focus();
}
}
}
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')