在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ iview 在使用render創(chuàng)建Input 組件時(shí),自動(dòng)獲取焦點(diǎn)只能觸發(fā)一次?

iview 在使用render創(chuàng)建Input 組件時(shí),自動(dòng)獲取焦點(diǎn)只能觸發(fā)一次?

用的iview框架,我想實(shí)現(xiàn)一個(gè)點(diǎn)擊按鈕,觸發(fā)Input的自動(dòng)獲取焦點(diǎn)的功能,關(guān)鍵代碼如下:

render: (h, params) => {
    if(params.index == this.editIndex){ //渲染Input組件
        return h('Input', {
            props: {
                value: params.row.name,
                autofocus: true    // iview Input組件,自動(dòng)獲取焦點(diǎn)參數(shù)
            },
            on: {
                "on-focus": (e) => {    //每次點(diǎn)擊input的時(shí)候可以選中文本
                    this.editIndexText = params.row.name
                    e.srcElement.select();
                },
                "on-blur": (e) => {    //修改index值,渲染文本
                    this.editIndex = -1;
                    console.log(e)

                },
                "on-keyup": (e) => {
                    console.log(e)
                    if(e.code == "Enter"){
                        this.editIndex = -1;
                    }
                }
            }
        }, params.row.name)
    }else{    //渲染文本
        return h('p', params.row.name)
    }

點(diǎn)擊修改時(shí),render渲染Input組件,自動(dòng)獲取焦點(diǎn),但是實(shí)現(xiàn)效果,只有第一次顯示。

clipboard.png

原因是為什么,有解決方案么。。。研究好久了。。。求大神告知....

回答
編輯回答
陪她鬧

原因未知,
使用ref 指定 Input ,點(diǎn)擊修改的使用 $nextTick 可以解決

vm.$nextTick(() => {
    vm.$refs.tableInput[0].focus()
})
2017年3月28日 04:08