您的位置:首页 > 移动开发 > 微信开发

微信小程序form表单的应用

2017-03-28 01:17 555 查看
<form bindsubmit="formSubmit" bindreset="formReset">
<view>选择类别:</view>
<view class="section section_gap">
<radio-group name="radio-group">
<label><radio value="radio1"/>爱情</label>
<label><radio value="radio2"/>事业</label>
<label><radio value="radio3"/>友情</label>
<label><radio value="radio4"/>责任</label>
<label><radio value="radio5"/>前途</label>
</radio-group>
</view>

<text class="txt">我的姓名:</text>
<view class="section">
<input name="input" />
</view>

<text>我的头衔:</text>
<view class="section">
<input name="input"/>
</view>

<text class="txt">介绍一下我自己:</text>
<view class="section1">
<textarea placeholder="" focus="{{focus}}" />
</view>

<text class="txt">需要支付:</text>
<view class="section" type="number">
<input name="input" placeholder="0.01" />
</view>

<view class="btn-area">
<button formType="submit" style="background:#ff9900">提交</button>
</view>
</form>
Page({
data: {
height: 20,
focus: false
},
bindButtonTap: function() {
this.setData({
focus: true
})
},
bindTextAreaBlur: function(e) {
console.log(e.detail.value)
},
bindFormSubmit: function(e) {
console.log(e.detail.value.textarea)
},
formSubmit: function(e) {
console.log('form发生了submit事件,携带数据为:', e.detail.value)
},
formReset: function() {
console.log('form发生了reset事件')
}
})

.section{
border:1px solid #ddd;
width:96%;
margin:auto;
height:80rpx;
margin-top:20rpx;
}
.section1{
border:1px solid #ddd;
width:96%;
margin:auto;
margin-top:20rpx;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: