美文网首页
ionic 跨页面实时传值

ionic 跨页面实时传值

作者: 咔簌 | 来源:发表于2018-03-13 13:29 被阅读0次
    官方文档的调用方式
    import { Events } from 'ionic-angular';
    
    constructor(public events: Events) {}
    
    // first page (publish an event when a user is created)
    function createUser(user) {
      console.log('User created!')
      events.publish('user:created', user, Date.now());
    }
    
    // second page (listen for the user created event)
    events.subscribe('user:created', (user, time) => {
      // user and time are the same arguments passed in `events.publish(user, time)`
      console.log('Welcome', user, 'at', time);
        });
    

    Events 有三个方法 分别是:

    this.events.publish ()        //注册Events事件
    this.events.subscribe()        //调用Eevents事件
    this.events.unsubscribe()        //注销Events事件q

    相关文章

      网友评论

          本文标题:ionic 跨页面实时传值

          本文链接:https://www.haomeiwen.com/subject/rikzfftx.html