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

有些话、适合烂在心里 提交于 2019-12-23 14:58:34
<!--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)
  }
})
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!