rhanb/nativescript-bottombar

How to use the selectItem method using Vue?

jujogi opened this issue · 3 comments

How would be the correct way to use this method?
May be have an example?
Thanks!

Bind the on loaded listner on your component.

<BottomBar row="1" v-on:loaded="barLoaded">
        <BottomBarItem icon="~/assets/images/icons/ic_home_filled.png" title="Home"
        >
    </BottomBar>

And at your method just use the event.object.

           barLoaded: function(event){
                const bar = event.object;
                bar.selectItem(bar.menuItemIndex);
            }

Hope it help!

Hi @fabioaraujo121, thanks for answering!

I'm trying to change selected BottomBar Item when I change the active page using the SideDrawer.
I'm tryed using Event Bus to comunicate both components but I don't know how to use selectItem in this case.

Any ideas?

Change page method in my SideDrawer

    changePage() {
      EventBus.$emit('bottom-bar-item', 1);
      this.closeDrawer();
    },

Receiving event in my BottomBar component

EventBus.$on("bottom-bar-item", barItem => {
  this.selectItem(0); //error
  this.barLoaded(barItem); //error
  console.dir(barItem); //return 1
});

Thanks for help!
Regards,

rhanb commented

Hi @jujogi ,

This is not an issue from the library itself. This should be on stackoverflow or equivalent.
Closing the issue.