Skip to content

How to detect active route? #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
huyaxiong opened this issue Mar 19, 2020 · 2 comments
Closed

How to detect active route? #28

huyaxiong opened this issue Mar 19, 2020 · 2 comments

Comments

@huyaxiong
Copy link

huyaxiong commented Mar 19, 2020

Lets say I have some tabs at the bottom of the page, each tab relates to a corresponding route, When I click a tab, I want to give some highlight to this tab so the user knows that he clicked this tab, so how could I detect it?

<Page actionBarHidden="true">
    <GridLayout rows="*, auto">
      <Navigator :defaultRoute="isLoggedIn ? '/home' : '/login'"/>
      <GridLayout id="bottom-bar" backgroundColor="#fff" row="1" columns="*">
        <FlexboxLayout justifyContent="space-around" alignItems="center" class="nav" col="0" >
          <Label @tap="goTo('/home')" text.decode="&#xe607;"
                 class="iconfont"/>
          <Label @tap="goTo('/home')" text.decode="&#xe609;"
                 class="iconfont"/>
          <Label @tap="goTo('/profile')" text.decode="&#xe60a;"
                 class="iconfont"/>
          <Label @tap="goTo('/profile')" text.decode="&#xe608;"
                 class="iconfont"/>
        </FlexboxLayout>
      </GridLayout>
    </GridLayout>
  </Page>

Codes above are the structure I have.

@rigor789
Copy link
Member

$navigator.path will contain the active path. You could apply a class to the current item

<Label @tap="goTo('/profile')" 
   text.decode="&#xe608;"
  :class="{ active: $navigator.path === '/profile' }"
   class="iconfont"/>

@huyaxiong
Copy link
Author

$navigator.path will contain the active path. You could apply a class to the current item

<Label @tap="goTo('/profile')" 
   text.decode="&#xe608;"
  :class="{ active: $navigator.path === '/profile' }"
   class="iconfont"/>

thank u, it works as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants