<view class="form">
<view class="form-input">
<view class="label">昵称</view>
<input class="input" value="{{nickname}}" placeholder="请输入昵称" type="text"></input>
</view>
<view>
<button bindtap="doSubmit" class="btn-submit">确 定</button>
</view>
</view>
var a = getApp();
Page({
data: {
nickname:'',
},
doSubmit: function doSubmit() {
const e = this.data.nickname;
wx.showModal({
title:e
});
}
});
//wxml <view class="form"> <form bindsubmit="doSubmit"> <view class="form-input"> <view class="label">昵称</view> <input class="input" name="nickname" value="{{nickname}}" placeholder="请输入昵称" type="text"></input> </view> <view> <button form-type="submit" class="btn-submit">确定 </button> </view> </form> </view> //js doSubmit(e) { const value = e.detail.value; wx.showModal({ title:value.nickname }); }
已经搞定。value前面要加model:value
你都没赋值又怎么可能会显示
nickname没有进行赋值,bindinput 或者 bindblur
你这写法不对吧