Javascript 使用元素ui和vue js在更改select后设置输入焦点
我正在选择一种产品,在“选择产品”对话框中,您必须将焦点传递给数量输入,我使用ref,但它对我不起作用Javascript 使用元素ui和vue js在更改select后设置输入焦点,javascript,vue.js,element-ui,Javascript,Vue.js,Element Ui,我正在选择一种产品,在“选择产品”对话框中,您必须将焦点传递给数量输入,我使用ref,但它对我不起作用 当您需要以Vue外部的方式修改UI时,一个有用的技巧是调用。在您的情况下,这将推迟对focus的调用,直到用户界面在选择后完成更新 ChangueSelectProduct(){ this.$nextTick(()=>this.$refs.cantidad1.focus()) } 当您需要以Vue外部的方式修改UI时,一个有用的技巧是调用。在您的情况下,这将推迟对focus的调用,直到用户界
当您需要以Vue外部的方式修改UI时,一个有用的技巧是调用。在您的情况下,这将推迟对
focus
的调用,直到用户界面在选择后完成更新
ChangueSelectProduct(){
this.$nextTick(()=>this.$refs.cantidad1.focus())
}
当您需要以Vue外部的方式修改UI时,一个有用的技巧是调用。在您的情况下,这将推迟对focus
的调用,直到用户界面在选择后完成更新
ChangueSelectProduct(){
this.$nextTick(()=>this.$refs.cantidad1.focus())
}
<el-select
ref="select1"
v-model="EntradaProducto.ProductoSucursalId"
filterable
style="width: 50%"
remote
@change="ChangueSelectProduct"
placeholder="Escriba nombre del producto"
:remote-method="remoteMethodSearchProduct"
:loading="loadingSearchProduct">
<el-option
v-for="item in optionsProducts"
:key="item.id"
:label="item.descripcion"
:value="item.id">
<span style="float: left">{{ item.marca +' | '+ item.descripcion }}</span>
<span style="float: right; color: #8492a6; font-size: 13px">S/ {{ item.precio }}</span>
</el-option>
</el-select>
<el-input
ref="cantidad1"
type="number"
style="width: 90px"
placeholder="Cant"
v-model="EntradaProducto.Cantidad"
></el-input>
ChangueSelectProduct(){
this.$refs.cantidad1.select();
this.$refs.cantidad1.focus();
},