Home > Web Front-end > uni-app > body text

How to get the value of text in uniapp

coldplay.xixi
Release: 2020-12-18 14:54:01
Original
6914 people have browsed it

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>
Copy after login

2. Define an inputcontent

data() {
return {
inputcontent:&#39;&#39;,//输入内容
};
},
Copy after login

## 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);
},
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template