Skip to content

tab-view selectedIndex should be selectedTab #50

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
saknarak opened this issue Sep 20, 2017 · 0 comments
Closed

tab-view selectedIndex should be selectedTab #50

saknarak opened this issue Sep 20, 2017 · 0 comments

Comments

@saknarak
Copy link

In sample samples/app/app-with-tab-view.js

<tab-view :selectedIndex="selectedTab">

But in file platform/nativescript/runtime/components/tab-view.js has prop selectedTab

export default {
  name: 'tab-view',

  props: ['selectedTab'],

I try to change two-way binding but it's not work

export default {
  name: 'tab-view',
  model: {
    prop: 'selectedTab',
    event: 'selectedTabChanged',
  },
  props: ['selectedTab'],

  template: `<native-tab-view ref="tabView" v-model="selectedIndex"><slot></slot></native-tab-view>`,

  data() {
    return {
      selectedIndex: 0
    }
  },

  watch: {
    selectedTab(index) {
      this.selectedIndex = index
    },
    selectedIndex(index) {
      this.$emit('selectedTabChanged', index)
    },
  },

  methods: {
    registerTab(tabView) {
      let items = this.$refs.tabView.nativeView.items || []

      this.$refs.tabView.setAttribute('items', items.concat([tabView]))
    }
  }
}

NOT WORK

<tab-view v-model="curTabIndex"></tab-view>

WORK

<tab-view :selectedTab="curTabIndex" @selectedTabChanged="idx => curTabIndex = idx"></tab-view>

@rigor789 rigor789 added the bug label Sep 20, 2017
@rigor789 rigor789 added this to the v1.0.0 milestone Nov 24, 2017
@nativescript-vue nativescript-vue locked as resolved and limited conversation to collaborators May 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants