Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.1k views
in Technique[技术] by (71.8m points)

将input每次获取输入框的值组合成一个数组

image.png

`

             <view 
               v-for="(con, indexCon) in item.select_question"
                        :key="indexCon">
                         <input
                            type="text"
                            :maxlength="item.number_of_characters"
                            class="moreinput"
                            :placeholder="con.input_title"
                            :value="con.value"
                            :disabled="dis"
                            :name="item.question_id"                
                            @input="value => onKeyInputMore(value,item.question_id,item.select_question.length,indexCon)"
                        />
                    </view>`
onKeyInputMore(event, questid,lengthNum,index) {
            var value = event.target.value;
}

怎么在下面事件里面把每一次监听的value值都组装成一个数组。或者能取到所有input输入的值,组成一个数组,请问要怎么做呢


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

vue自带的v-model没必要拆开value和@input,可以利用计算属性computed来获取这个数组

result: function(){
    return this.item.select_question.map(con => con.value)
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...