一、vue下input文本框得到光標html
html:vue
<el-input size="mini" clearable v-model.trim="addOrEditData.gridCode" ref="inputGridCode" ></el-input>
js(在須要觸發獲取input光標方法加入下面js,若是須要再進入頁面得到就得到光標則在vue鉤子函數mounted加上下面代碼:):函數
this.$refs.inputGridCode.focus();
二、vue中input文本框內容選中this
方法一:spa
html:code
<el-input size="mini" clearable v-model.trim="addOrEditData.gridCode" ref="inputGridCode" @@focus="inputFocus($event)"></el-input>
js方法:htm
inputFocus(event) {
event.currentTarget.select();
}
方法二:blog
html:get
<el-input size="mini" clearable v-model.trim="addOrEditData.gridCode" ref="inputGridCode" ></el-input>
js:input
this.$refs.inputGridCode.select();