---
title: "微信小程序开发笔记 REVIEW20170317"
author: "FZtree"
date: "2018-03-17T21:00:36Z"
tags: []
categories: ["移动开发"]
slug: "review20170317"
draft: false
lastmod: "2018-03-17T21:00:36Z"
id: 2413430
url: "https://fztree.iteye.com/blog/2413430"
---

框架   -&gt;MVW Angular

组件   -&gt;DTD &lt;brand new&gt;

API    -&gt;Service

js语法 -&gt;阅读简易教程::Q&A

 

 

sample\_4.0

------pages/index/index.wxml------

&lt;button bindtap='kaka'&gt;{{r\_count}}&lt;/button&gt;

 

------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) =&gt; {

    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}

})