uni-app中form表单提交获取input的值

时间:2024-01-31 10:20:23

代码:

<form @submit="onNick" class="pass_form">  
  <input name="text" class="uni-input" type="text" @input="onInput" :value="value" placeholder="请输入自己喜欢的昵称"/>   
   <button form-type="submit"  class="person_submit">确定</button>  
</form> 
onNick:async function(e){
  var that = this;
   let nickname = e.detail.value.text;
   let data = await this.$http.post(\'/mini/reset_nickname\',{\'nickname\':nickname}
     ).then(function(data){
        that.$refs.nick.close();
         uni.showToast({
         title:"昵称修改成功",
         icon:\'none\',
         duration: 2000
                        
      })
      that.personData.nickname = nickname
  }).catch(function(data){});
},
//获取input的数据 onInput(e) {   
this.$emit(\'input\', e.detail.value) } ,

图片效果