官方提供的IDE虽然编辑功能比较弱,但是有一个功能很不错——自动创建页面基本文件。当在app.json
里面增加一个pages
的页面配置的时候,IDE会自动创建对应的目录和四个基本文件。这比手动一个一个创建快捷得多。
把需要开发调试的页面放到app.json
中pages
的第一个位置的时候,打开app就是这个页面。
可以在表单bindblur
时间中将表单值保存起来
Page({
listenerPhoneInput: function(e) {
this.data.mobile = e.detail.value;
},
getPhoneInput: function(e) {
console.log(this.data.mobile)
},
})
<view class="section">
<input bindblur="listenerPhoneInput" type="number" />
<button bindtap="getPhoneInput"> 登录 </button>
</view>
function countdown(that) {
var second = that.data.second;
if (second == 0) {
that.setData({
second: "0s"
});
return ;
}
var time = setTimeout(function(){
that.setData({
second: second - 1
});
countdown(that);
}, 1000);
}
Page({
data : {
second : '倒计时效果',
},
demo: function(e) {
this.data.second = 60;
countdown(this);
},
})
<view class="section">
<button type="warn" bindtap="demo"> {{second}} </button>
</view>
线上应用是用白名单来限定可访问的URL的,不过开发的时候这样很不方便,可以勾选【项目】里的【开发环境下不校验请求域名以及TLS版本】。
IDE里的【调试】->【缓存】可以清理各种本地缓存,不必专门写代码去清理。