pyplayer
V2EX  ›  微信

最近搞小程序,问下微信小程序如何让孙子组件直接触发祖先组件,有类似上下文的东西吗

  •  
  •   pyplayer · Jul 20, 2020 · 2868 views
    This topic created in 2302 days ago, the information mentioned may be changed or developed.
    9 replies  •  2020-07-20 10:56:15 +08:00
    wysnylc
    wysnylc
    Jul 20, 2020
    1
    专业点,子级和父级
    ly61
    ly61
    Jul 20, 2020
    2
    祖先...
    Kim1am
    Kim1am
    Jul 20, 2020
    3
    说实话,没太理解你的需求~或者你可以选择自己手写一个简易 eventBus ?祖先组件注册监听事件,孙子组件直接 emit 。你看看这样可以不?
    HongJay
    HongJay
    Jul 20, 2020
    4
    这是不是哪个前端文档的称呼。。
    takemeaway
    takemeaway
    Jul 20, 2020
    5
    冒泡啊
    pyplayer
    pyplayer
    OP
    Jul 20, 2020
    6
    @takemeaway 一层层 triggerEvent 上去吗
    newtype0092
    newtype0092
    Jul 20, 2020
    7
    @HongJay
    以前教科书上有用“祖先”和“子孙”的,孙子过分了😂
    ypcs03
    ypcs03
    Jul 20, 2020
    8
    哈哈 看标题以为是来搞笑的 孙子级听起来有点儿怪怪的
    takemeaway
    takemeaway
    Jul 20, 2020
    9
    @pyplayer 小程序冒泡是自动的吧? 另外你层级多的话,干嘛要分父子,直接绑定一个层级啊。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1492 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 10:11 · PVG 18:11 · LAX 02:11 · JFK 05:11
    ♥ Do have faith in what you're doing.