How to get the text value in uniapp: first fill in the text box and define an inputcontent in data; then write the event in methods, the code is [this.inputcontent = e.target.value].
The operating environment of this tutorial: windows7 system, uni-app2.5.1 version. This method is suitable for all brands of computers.
Recommended (free): uni-app development tutorial
How to get the text value in uniapp :
1. Write text box
<view class="b-input-button"> <view class="askQue" v-if="$store.state.wz.dzaskQuestion"> <input type="text" @input="onInput" placeholder="请输入..." v-model="inputcontent" :value="inputcontent" class="b-askQue-input" /> </view> <button @click="send" class="b-button">确定</button> </view>
2. Define an inputcontent
data() { return { inputcontent:'',//输入内容 }; },
## in data #3. Write events in methods
//获取input文本框中的输入值 onInput(e){ this.inputcontent = e.target.value }, /** * 触发确定按钮 */ send() { let valsrc = ''; let valadd = ''; valsrc = this.inputcontent; if (!valsrc) { uni.showToast({ title:"请输入...", duration: 2000 }) return; } valadd = valsrc; this.inputcontent = ''; this.$store.commit('updateDzQuestionNum', -4); this.show(false, valadd); },
The above is the detailed content of How to get the value of text in uniapp. For more information, please follow other related articles on the PHP Chinese website!