pages > html文件夹 > js + json +wxml + wxss wxml: view ≈ div text ≈ span <view class=‘inputs {{addressChange?"":"noData"}}‘ catchtap=‘getAddress‘> {{addressChange?"":"noData"}} catchtap 方法绑定 无冒泡 <view class=‘lytGrailCon‘><input bindinput ="iStoreName" value="{{sStoreName}}" placeholder=‘请输入公司/店铺/网店名称‘ placeholder-class="gray"></input></view> bindinput placeholder-class input的placeholder颜色设置样式 <picker bindchange=‘pickChange‘ data-param="sltType" value=‘{{sltType.index}}‘ range=‘{{sltType.arr}}‘> <text>{{sltType.show}}</text> </picker> 下面弹出选择器 单选 bindchange=‘pickChange‘ range=‘{{sltType.arr}}‘ <block wx:for=‘{{sltCategory.arr}}‘ wx:key=‘unique‘> <text data-index=‘{{index}}‘ class=‘{{item.checked?"cur":""}}‘ catchtap=‘choCategory‘>{{item.name}}</text> </block> json: { "navigationBarTitleText": "wx标题" } wxss: 单位:rpx js: var app = getApp(); data > { 页面展示数据 } ≈ avalon define data平级方法 注意this var _this = this; _this.setData({ addressChange:true }) 改变data里面的值 input 绑定的方法 iStoreName:function (e) { var _this=this; var val=e.detail.value; if(_this.handleVal.notEmpty(val)){ if(val.length<=30){ }else { _this.showSToast(‘公司名称输入过长‘); val=val.substr(0,30); console.log(val) } }else { _this.showSToast(‘请输入公司名称‘); } _this.setData({sStoreName: val}) }, picker 绑定的方法 pickChange:function (e) { var _this=this; var _param=e.currentTarget.dataset.param; var show; switch (_param){ case ‘sltCategory‘:show=this.data.sltCategory.arr[e.detail.value];break; case ‘sltType‘:show=this.data.sltType.arr[e.detail.value];break; case ‘sltSales‘:show=this.data.sltSales.arr[e.detail.value];break; default: break; } var _obj={ index:_param+‘.index‘, show:_param+‘.show‘, isChange:_param+‘.isChange‘ }; _this.setData({ [_obj.index]:e.detail.value, [_obj.show]:show, [_obj.isChange]:true }) }, wx ajax请求 wx.request({ url: app.globalData.ajxApi(‘请求url‘), header: {‘content-type‘: ‘application/x-www-form-urlencoded‘}, data: {jsonObj:JSON.stringify(objJson)}, method: ‘POST‘, success: function(res){}, fail: function() {} }) wx 关闭当前开下个窗口 wx.redirectTo({ url: ‘../URL‘ })
原文地址:https://www.cnblogs.com/caiCheryl/p/8267598.html
时间: 2024-10-10 00:08:00