微信小程序(页面获取组件实例对象来操做组件)

<!--index.wxml-->
<view class="container">
  <button bindtap="count">计数</button>
  <my-count id="count"></my-count>
</view>
//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    title:"这是页面传的数据",
    cates:['推荐','热门','时尚','娱乐']
  },
  onLoad: function () {
    
  },
  search:function(e){
    console.log(e.detail.searchText);
  },
  itemClick: function(e){
    console.log(e.detail);
  },
  count:function(){
    // console.log(this.selectComponent('#count'))
    this.selectComponent('#count').increase(10);
    console.log(this.selectComponent('#count').data.counter)
  }
})
已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 代码科技 设计师:Amelia_0503 返回首页