框架 ->MVW Angular
组件 ->DTD
API ->Service
js语法 ->阅读简易教程::Q&A
sample_4.0
------pages/index/index.wxml------
------pages/index/index.js------
var obj={
//默认数据结构data,初始化DTD的变量
data:{r_count: 100},
//定义函数 kaka
kaka: function(){
this.setData({r_count:this.data.r_count+1});
//避免直接对 Page.data 进行赋值! 请使用 Page.setData 进行操作.
}
};
page(obj);
------page/index/index.json------
{"navigationBarTitleText": "我的第一个小程序"}
https://mp.weixin.qq.com/debug/wxadoc/dev/api/network-file.html#wxuploadfileobject
看到这里 js变后端语言了
const uploadTask = wx.uploadFile({});
uploadTask.onProgressUpdate((res) => {
console.log('上传进度', res.progress)
console.log('已经上传的数据长度', res.totalBytesSent)
console.log('预期需要上传的数据总长度', res.totalBytesExpectedToSend)
});
uploadTask.abort(); // 取消上传任务
https://mp.weixin.qq.com/debug/wxadoc/dev/framework/config.html
打开debug选项, 看到:
App: onLaunch have been invoked
App: onShow have been invoked
Register Page: pages/index/index
Register Page: pages/logs/logs
On app route: pages/index/index
Update view with init data
pages/index/index: onLoad have been invoked
pages/index/index: onShow have been invoked
Invoke event onReady in page: pages/index/index
pages/index/index: onReady have been invoked
秒懂,重写两个控制器
------app.js------
//app.js
App({
onLaunch : function () {console.log("\t 11")},
onShow : function () {console.log("\t 12")},
app_data : {age:29},
})
------pages/index/index.js------
//index.js
const app = getApp() //获取应用实例
Page({
onLoad : function () {console.log("\t 21")},
onShow : function () {console.log("\t 22")},
onReady : function () {console.log("\t 23")},
data : {r_count: app.app_data.age}
})