小程序代码

82 阅读1分钟

主题列表:juejin, github, smartblue, cyanosis, channing-cyan, fancy, hydrogen, condensed-night-purple, greenwillow, v-green, vue-pro, healer-readable, mk-cute, jzman, geek-black

贡献主题:github.com/xitu/juejin…

theme: juejin highlight: ··· 最近学习小程序开发。 我 把一个子组件 js 代码 最外层写成Page 生命周期不触发, 写成Component , weui 不起作用 ,有没有人说下原因的吗

//index.js
const app = getApp()
// import '';
Page({
  data(){
    return {
  }},
  properties: {
    tid:String
  },
  lifetimes:{
    attached(){
      console.log("onload",arguments);
     wx.getStorage({
       key: "click"+this.properties.tid,
      success:(res)=>{
        if(res.data)
        this.setData(res.data)
      }
     })
      // getApp().setWatcher(this); // 设置监听器
    },
    detached: function () {
      console.log(this.data)
      return wx.setStorage({key:"click"+this.properties.tid,data:this.data
      })
    },
···