Article From:

When modifyAct becomes true, TD renders as input. This time, you want input to be the default selected state, but you don’t know what data binding should do to focus.


<td ms-if="!item.modifyAct" ms-click="modifyAct(index)">
    <input type="hidden" ms-duplex="item.actNum" :attr="{name:item.actName}"/>
<td ms-if="item.modifyAct" >
    <input class="layui-input2" ms-blur="modifyAct(index)" :attr="{autofocus:true}" autocomplete="off"  ms-duplex="item.actNum" />


    this.list[index].modifyAct= !this.list[index].modifyAct;


After clicking, I hope this input can be selected by default.

Answer 0:

Finally, solved by JQ.
Because of ms-if judgment, there is only one input blur when modifyAct is changed to false.

But the feeling is still stiff. It’s not a good idea.
For example, when modifyAct is true, you can’t find the element $(“. layui-input2”) until the view is rendered?

Leave a Reply

Your email address will not be published. Required fields are marked *