// pages/home/home.js Page({ /** * 页面的初始数据 */ data: { title: 'header', userInfo: '', content: '我是父组件的content', footContent: "bottomContent", background: [{class:'header-swiper-one',content:'数据分析'}, {class:'header-swiper-two',content:'前端开发'}, {class:'header-swiper-three',content:'全栈开发'}], indicatorDots: true, headerContent:'swiper', vertical: false, autoplay: true, interval: 5000, duration: 1000, menuIsShow:false, bottomBtn:'front' }, // 监听 watch:{ bottomBtn:function(newVal,oldVal){ console.log('监听',newVal,oldVal) } }, // 自定义函数 changeIndicatorDots() { this.setData({ indicatorDots: !this.data.indicatorDots }) }, changeAutoplay() { this.setData({ autoplay: !this.data.autoplay }) }, intervalChange(e) { this.setData({ interval: e.detail.value }) }, durationChange(e) { this.setData({ duration: e.detail.value }) }, // 关闭菜单 menuClose(){ this.data.menuIsShow&&this.setData({ menuIsShow: !this.data.menuIsShow }) }, menuSwitch(){ this.setData({ menuIsShow: !this.data.menuIsShow }) }, // 导航的按钮 clickBottomBtn(e){ const label=e.currentTarget.dataset.label||'front' console.log('click',label) this.setData({ bottomBtn:label }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { console.log('进入home页面' ,12431243) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })