Coder Social home page Coder Social logo

Comments (7)

luckyadam avatar luckyadam commented on May 7, 2024

我们组件化是自己实现的,没有用小程序组件那一套,所以生命周期都可以自定义咯~
而页面的生命周期有依赖与小程序页面生命周期,componentDidMount 大致等价于小程序的 onReady 方法

from taro.

honchy avatar honchy commented on May 7, 2024

@luckyadam

不过在小程序里面运行的时候,什么时机触发的componentDidMount呢?因为小程序没有类似的时机可用,怎么知道已经插入到真实的 DOM,或者已经从 DOM 卸载掉呢?

from taro.

luckyadam avatar luckyadam commented on May 7, 2024

@honchy 小程序页面有 onReady 方法的

from taro.

honchy avatar honchy commented on May 7, 2024

@luckyadam 具体到组件呢,比如自定义了一个 Button 组件,Button 组件会有这些生命周期方法吗?

from taro.

luckyadam avatar luckyadam commented on May 7, 2024

嗯嗯,有的,组件同样有生命周期~ 组件生命周期依赖于页面生命周期来实现~

from taro.

honchy avatar honchy commented on May 7, 2024

cool

from taro.

silent-tan avatar silent-tan commented on May 7, 2024

有个疑问是为什么把didshow放在didmount前执行?有个场景是当前业务只在挂载完成的时候执行一次,然后每次页面展示的时候执行另外的业务,场景应该不少见。(willmount非异步很绝望)即是

componentDidMount() {
    // 只在第一次加载的时候执行
    checkLogin()
}
componentDidShow() {
    // 页面加载时候执行
    runDependenceLogin()
}

@luckyadam

from taro.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.