Nativescript-vue: TabView selectedIndex is prop so how do you get the index?

Created on 17 Oct 2018  路  5Comments  路  Source: nativescript-vue/nativescript-vue

Version

2.0.2

Reproduction link

https://play.nativescript.org/?template=play-vue&id=o5jFvQ&v=5

Platform and OS info

ios

Steps to reproduce

The docs say selectedIndex "gets or sets" the current index and its a prop. How do you get the selectedIndex if its a prop? If you do v-model="selectedIndex" I get an object not a int

What is expected?

get current index

What is actually happening?

either it stays 0 on tab change with :selectedIndex="selectedIndex" orv-model="selectedIndex"` I get an object

normal

Most helpful comment

@rigor789 Just came across this thread now and can confirmv-model not working , but :selectedIndex="selectedIndex" @selectedIndexChange="selectedIndex = $event.value"

All 5 comments

The reproduction link does not show the issue you are describing, in fact it doesn't show anything when I run it. The HelloWorld component does not have a template nor a page tag, can you update the reproduction to actually show the issue you are facing?

@rigor789 sorry, in my daze late last night I forgot some stuff. I updated the link. You can see that when the tab is switch the index should be got from 0 to 1 and the text should change, it does not.

Props are one way, from parent to child. Changing it to v-model="selectedIndex" should work.

What v-model does is roughly something like :selectedIndex="selectedIndex" @selectedIndexChange="selectedIndex = $event.value"

Although I just created a test project locally, and v-model doesn't seem to be working. Will look into it. The above way (what v-model should be doing) is how you can do a two way binding.

@rigor789 Ya I understand v-model and how props are one way. I was just pointing out v-model doesnt work on this tabview (returns an object) and the docs make it sound like :selectedIndex prop is a getter too. I would recommend changing the docs to point out using v-model to get the index when it works. Thanks

@rigor789 Just came across this thread now and can confirmv-model not working , but :selectedIndex="selectedIndex" @selectedIndexChange="selectedIndex = $event.value"

Was this page helpful?
0 / 5 - 0 ratings