Article From:https://segmentfault.com/q/1010000011697129
Question:

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.

html:

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

js:

modifyAct:function(index){
    this.list[index].modifyAct= !this.list[index].modifyAct;
}

Picture:


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?

Similar Posts:

Leave a Reply

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