uview input输入框自动聚焦并选中文本

777 阅读1分钟
<input :focus="focus" selection-start="0" :selection-end="selectionLength" />

利用selection-start和selection-end可实现,其中selectionLength为输入框值的长度,即:

<u-input v-model="barcode2" placeholder="请输入料箱条码" clearable :focus="code2Focus" selection-start="0" :selection-end="form.barcode2.length"/>