用户工具

站点工具


mina:page_function

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录前一修订版
后一修订版
前一修订版
mina:page_function [2020/08/24 15:26] – [4. 使用 behaviors()] sabertoymina:page_function [2020/08/24 15:36] (当前版本) – [5. 使用 Component] sabertoy
行 169: 行 169:
 ===== -#5 使用 Component ===== ===== -#5 使用 Component =====
  
 +Page 构造器适用于简单的页面。但对于复杂的页面, Page 构造器可能并不好用。
 +
 +[[https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/component.html | Component]] 构造器的主要区别是:<wrap em>方法需要放在 methods: { } 里面</wrap>
 +
 +<code javascript>
 +Component({
 +  data: {
 +    text: "This is page data."
 +  },
 +  methods: {
 +    onLoad: function(options) {
 +      // 页面创建时执行
 +    },
 +    onPullDownRefresh: function() {
 +      // 下拉刷新时执行
 +    },
 +    // 事件响应函数
 +    viewTap: function() {
 +      // ...
 +    }
 +  }
 +})
 +<code>
  
mina/page_function.1598253968.txt.gz · 最后更改: 2020/08/24 15:26 由 sabertoy