WEPY学习笔记

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/gexiuhua/article/details/79813513

小程序之WEPY学习笔记

  1. WEPY风格与Vue大同小异
  2. 通过this.$parent来调用App示例
  3. 页面中的methods元素只能放置bind/catch等方法,其他方法跟methods同级
  4. WEPY当页面引入两个相同ID的组件时,这两个组件共用同一个实例与数据,当其中一个组件数据变化时,另外一个也会一起变化。如果需要避免这个问题,则需要分配多个组件ID和实例。
<template>
<child></child>
<anotherchild></anotherchild>
</template>

<script>
components = { 
    //为两个相同组件的不同实例分配不同的组件ID,从而避免数据同步变化的问题 
    child: Child, 
    anotherchild: Child 
};
</script>
  1. wx:for的替代
<repeat for="{{list}}" key="index" index="index" item="item">
     <!-- 插入<script>脚本部分所声明的child组件,同时传入item -->
     <child :item="item"></child>
</repeat>

猜你喜欢

转载自blog.csdn.net/gexiuhua/article/details/79813513