微信小程序页面监听组件内数据变化

1.页面中方法

   1.1 在组件引入页面后,在.js中新建一个方法

ComponentListener(e){
    //e.detail为组件中传递过来的数据
    console.log(e.detail)
}

  1.2 在模板中绑定上述方法

2.组件中方法,在需要的位置写入监听方法

attached() {
      this.triggerEvent("countDownListener",this.data.left_time)
}

你可能感兴趣的:(微信小程序,小程序)