Home  >  Article  >  Web Front-end  >  How to get the value of text in uniapp

How to get the value of text in uniapp

coldplay.xixi
coldplay.xixiOriginal
2020-12-18 14:54:016913browse

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].

How to get the value of text in uniapp

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:&#39;&#39;,//输入内容
};
},

## in data #3. Write events in methods

 //获取input文本框中的输入值
onInput(e){
    this.inputcontent = e.target.value
},
/**
* 触发确定按钮
*/
send() {
let valsrc = &#39;&#39;;
let valadd = &#39;&#39;;
valsrc = this.inputcontent;
if (!valsrc) {
uni.showToast({
    title:"请输入...", 
duration: 2000
})
return;
}
 
valadd = valsrc;
this.inputcontent = &#39;&#39;;
this.$store.commit(&#39;updateDzQuestionNum&#39;, -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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn