After testing Vuex(3.0.1) in a Nativescript-vue (2.0) app I noticed that when using ModalView
s or ListView
s,
$store
is not available in the list items components or modal component. For now, use a StackLayout
for lists and I pass the $store
as a prop to the ModalView
:
<!-- Instead of a ListView -->
<StackLayout class="list-group">
<MyComponent v-for="item in items" :item="item" :key="item.id" class="list-group-item"/>
</StackLayout>
In MyComponent
, the method to open the modal is like:
import ItemForm from '../forms/ItemForm'
export default {
name: 'MyComponent',
props: {
item: { required: true, type: Object },
},
methods: {
openForm () {
const props = {item: this.item, store: this.$store} // props for ItemForm
this.$showModal(ItemForm, { props }) // Show ItemForm as a ModalView
},
},
}
Leave a comment
You want to react to this content or ask something to the author? Just leave a comment here!
Note that the comments are not publicly visible, so don't worry if you don't see yours.
All the information you give will only be visible to the author. We don't share anything with anyone.