第一题
// index.js
// 获取应用实例
const app = getApp()
Page({
data: {
result:"",
},
num1:0,
num2:0,
numValue:function(event){
if(event.target.id=="num1"){
this.num1=Number(event.detail.value)
}
if(event.target.id=="num2"){
this.num2=Number(event.detail.value)
}
},
compare(){
if(this.num1>this.num2){
this.setData({
result:"第一个数大"
})
}else if(this.num1<this.num2){
this.setData({
result:"第二个数大"
})
}else{
this.setData({
result:"两个数相等"
})
}
}
})
第二题
<!-- 第一个空 <form ________="formSubmit">-->
<form bindsubmit="formSubmit">
<view class="content">
<view> <input name="xm" type="text" placeholder="输入您的姓名:" placeholder-class="phcolor" /> </view>
<view> <input name="phone" type="text" placeholder="输入您的手机号:" placeholder-class="phcolor" /> </view>
<view>
<!-- <picker name="num" ___(2)____="____(3)____" range="{{picker.arr}}"> 参加婚礼人数:_______(4)__________ -->
<picker name="num" bindchange="pickerChange" range="{{picker.arr}}" value="{{index}}"> 参加婚礼人数:{{picker.arr[index]}}
</picker>
</view>
<!-- <button form-type="___(5)___">提交</button>-->
<button form-type="submit">提交</button>
</view>
</form>
Page({
data: {
picker: {
arr: ['1', '2', '3', '4', '5', '6'],
index: 0
}
},
pickerChange: function (e) {
console.log(e)
this.setData({
//___6___: e.detail.value
index: e.detail.value
})
},
formSubmit: function (e) {
console.log(e)
// ___*(7)___
var name = e.detail.value.xm
var phone = e.detail.value.phone
if (name && phone.length == 13) {
// ______(9) ________({
wx.showToast({
title: '提交成功',
icon: 'success',
duration: 1500
})
} else {
// ______(10) _______({
wx.showToast({
title: '信息错误',
icon: 'error',
duration: 1500
})
}
}
})
第三题
<view class="tab">
<view class="tab-item {{item==0?'active':''}}" bindtap="changeItem" id="0">粉色</view>
<view class="tab-item {{item==1?'active':''}}" bindtap="changeItem"id="1">绿色</view>
<view class="tab-item {{item==2?'active':''}}" bindtap="changeItem" id="2">蓝色</view>
</view>
<swiper current="{{item}}" circular="true" bindchange="changeTab">
<swiper-item>
<view style="background:pink;"></view>
</swiper-item>
<swiper-item>
<view style="background:green;"></view>
</swiper-item>
<swiper-item>
<view style="background:blue;"></view>
</swiper-item>
</swiper>
Page({
data: {
item: 0
},
changeItem(e) {
console.log(e)
this.setData({
item:e.target.id
})
},
changeTab(e) {
this.setData({
item: e.detail.current
})
}
})
第四题
<view class="container">
<form>
<view class="nn"> <text>姓名:</text> <input type="text" name="name" value="{{name}}" /> </view>
<view class="ss"> <text>性别:</text>
<radio-group name="gender"> <label wx:for="{{gender}}" wx:key="value">
<radio value="{{item.value}}" checked="{{item.checked}}"/>{{item.name}}
</label> </radio-group>
</view>
<view class="zz"> <text>喜欢的运动:</text>
<checkbox-group name="sports"> <label wx:for="{{sports}}" wx:key="*this">
<checkbox value="{{item.value}}" checked="{{item.checked}}"/>{{item.zm}}
</label> </checkbox-group>
</view>
</form>
</view>