pagination destructuring assignment value setting error - vue.js

I'm trying to use the pagination feature. I wrapped a ref about the page with params =ref , paginated with params in axios and decomposed the structure to define totalCount. But I don't know where the problem lies with the Uncaught(promise) TypeError:Cannot set properties of undefined(setting 'value') error in the console. What part of the code needs to be modified?
boardlist.vue
<template>
<div>
<table class="box">
<tbody>
<tr
v-for="forms in form"
:key="forms.id"
style="cursor: pointer;"
#click="NoticeDetail(forms.id)">
<td class="td_title">
{{ forms.title }}
</td>
<td class="text_center">
{{ forms.company }}
</td>
<td class="text_center">
{{ forms.company_url }}
</td>
<td class="text_center">
{{ forms.location }}
</td>
<td class="text_right">
{{ forms.date_posted }}
</td>
</tr>
</tbody>
<AppPagination
:current-page="params._page"
:page-count="pageCount"
#page="page => (params._page = page)" />
</table>
</div>
</template>
<script setup>
import { useRouter } from 'vue-router'
import Sidebar from '~/components/Sidebar.vue'
import { ref,computed,watchEffect } from 'vue'
import axios from 'axios'
import AppPagination from '~/components/AppPagination.vue'
const router = useRouter()
const form = ref([])
const params = ref({
_page: 1,
_limit: 10,
})
const totalCount = ref(0)
const pageCount = computed(() =>
Math.ceil(totalCount.value / params.value._limit),
)
const username = sessionStorage.getItem('user')
const fetchPosts = async (params) =>{
console.log(params)
axios.get('http://127.0.0.1:8000/jobs/all', {
params: {
params
}
})
.then((res)=>{
console.log(res.data)
const { totalCount, noticeList } = res.data;
form.value = noticeList;
totalCount.value = totalCount;
})
}
watchEffect(fetchPosts)
const NoticeWrite = () => {
router.push({
path: '/service_center/notice/notice_create',
})
}
const NoticeDetail = id => {
console.log(id)
router.push({
name: 'noticedetail',
params: {
id
}
})
}
</script>
pagination.vue
<template>
<nav
class="mt-5"
aria-label="Page navigation example">
<ul class="pagination justify-content-center">
<li
class="page-item"
:class="isPrevPage">
<a
class="page-link"
href="#"
aria-label="Previous"
#click.prevent="$emit('page', currentPage - 1)">
<span aria-hidden="true">«</span>
</a>
</li>
<li
v-for="page in pageCount"
:key="page"
class="page-item"
:class="{ active: currentPage === page }">
<a
class="page-link"
href="#"
#click.prevent="$emit('page', page)">{{
page
}}</a>
</li>
<li
class="page-item"
:class="isNextPage">
<a
class="page-link"
href="#"
aria-label="Next"
#click.prevent="$emit('page', currentPage + 1)">
<span aria-hidden="true">»</span>
</a>
</li>
</ul>
</nav>
</template>
<script setup>
import { computed } from 'vue'
const props = defineProps({
currentPage: {
type: Number,
required: true,
},
pageCount: {
type: Number,
required: true,
},
})
defineEmits(['page'])
const isPrevPage = computed(() => ({ disabled: !(props.currentPage > 1) }))
const isNextPage = computed(() => ({
disabled: !(props.currentPage < props.pageCount),
}))
</script>
<style lang="scss" scoped></style>

Related

I encounterd this error "Invalid prop: type check failed for prop "categoryId". Expected Number with value 13, got String with value "13""

When I changed the props data type from String to Number, I get the error.
Although I checked again and again for strange parts, I couldn't find it.
I don't know why It worked well with String type.
In the code below,
CategoryHome is the parent Component of CategoryShow.
Could you tell me Where are mistakes in my code?
The blow image is screen design.
// CategoryShow.vue
<script setup>
import axios from "axios";
import { ref, watch} from "vue"
import { useRoute, useRouter } from 'vue-router'
const route = useRoute()
const router = useRouter()
const props = defineProps({
categoryId: {
//type: String,
type: Number
}
})
const categories = ref([])
const singleCategory = ref({})
const recipes = ref([])
const getCategory = () => {
return axios.get('/api/categories/' + props.categoryId)
}
const getCategories = () => {
return axios.get('/api/categories')
}
const getRecipes = () => {
return axios.get('/api/categories/' + props.categoryId + '/recipes/')
}
const getCategoriesAndCategoryAndRecipes = async () => {
const res1 = await getCategories()
const res2 = await getCategory()
const res3 = await getRecipes()
singleCategory.value = res2.data
recipes.value = res3.data
categories.value = res1.data
}
// when created (in lifecycel hook)
getCategoriesAndCategoryAndRecipes()
// when category page is changed,
watch(route, () => {
if (!isNaN(props.categoryId))
{
getCategoriesAndCategoryAndRecipes()
}
})
</script>
<template>
<div class="left-container">
<div class="form-box">
<h4 style="margin-bottom: 20px; margin-top: 10px">RECIPE HOUSE</h4>
<form method="post" v-on:submit.prevent="addCategory">
<input type="text" v-model="newCategory">
</form>
</div>
<ul class="category_ul">
<li v-for="category in categories" :key="category.id">
<button class="btn btn-danger" v-on:click="deleteCategory(category.id)">Delete</button>
<router-link :to="{name: 'category.show', params: {categoryId: category.id }}">
<span>{{ category.title }}</span>
</router-link>
</li>
</ul>
</div>
<div class="right-container">
<span class="icon">
<i class="fas fa-utensils fa-lg"></i>
</span>
<div>
<span>{{ singleCategory.title }}</span>
<form method="post" v-on:submit.prevent="addRecipe">
<input type="text" v-model="newRecipe">
</form>
<ul style="margin-top: 15px;">
<li v-for="recipe in recipes">
<router-link :to="{name: 'recipe.show', params: {recipeId: recipe.id}}">
<span>{{ recipe.title }}</span>
</router-link>
</li>
</ul>
</div>
</div>
</template>
// CategoryHome
<script setup>
// import axios from "axios"
import { onMounted, ref } from "vue"
import { useRouter } from 'vue-router'
const router = useRouter()
const newCategory = ref('')
let categoryId = ''
async function initial() {
try {
const res = await axios.get('/api/max')
categoryId = res.data.id
console.log(typeof categoryId) // number
router.push({name: 'category.show', params: { categoryId: categoryId }})
} catch(err) {
console.log('error handling')
}
}
initial()
</script>
<template>
<div class="left-container">
<h4 style="margin-bottom: 20px; margin-top: 10px">RECIPE HOUSE</h4>
<form method="post" v-on:submit.prevent="addCategory">
<input type="text" v-model="newCategory">
</form>
</div>
</template>
In CategoryHome, console.log(typeof categoryId) output number.
Are categoryId's data type in CategoryHome and categoryId's data type in props in CategoryShow not matching?
Thank you for your help.
I'm sorry My Englsh is not very good.

Vue 3 - [Vue warn]: Invalid vnode type when creating vnode

I have the following code:
<script setup>
import {ref, defineAsyncComponent, computed, reactive} from 'vue'
import {useMainStore} from '#/store/main.js'
import {useTableStore} from "#/store/tables";
import DefaultLayout from '#/layouts/DefaultLayout.vue'
import { storeToRefs } from 'pinia'
const tableStore = useTableStore()
const { userData } = useMainStore()
tableStore.getTables()
const { freeTables, usedTables } = storeToRefs(useTableStore())
const { tables } = storeToRefs(useTableStore())
const loading = ref(false)
const showOrder = ref(false)
let props = reactive({
orderID: null,
id: null,
})
const tableOrderComponent = computed(() => showOrder.value ? defineAsyncComponent(() =>
import("#/components/TableOrder.vue")) : ''
)
let tableOrder = (table) => {
props.id = parseInt(table.id, 10)
props.orderID = table.activeOrderID || null
showOrder.value = true
}
</script>
<template>
<DefaultLayout>
<template #default>
<div class="row come-in">
<div class="card col">
<div class="card-header">
<span class="text-capitalize"> {{ userData.username }}</span>
</div>
<div class="card-body subheader">
Used Tables ({{ usedTables.length }})
</div>
<ul class="list-group list-group-flush">
<li v-for="table in usedTables">
{{ table.name }}
</li>
</ul>
<div class="card-body subheader">
Free Tables ({{ freeTables.length }})
</div>
<ul class="list-group list-group-flush">
<li v-for="table in freeTables">
{{ table.name }}
<a href="#" v-tooltip="'Add order to the table'" #click="tableOrder(table)">
<font-awesome-icon icon="fas fa-list-alt" />
</a>
</li>
</ul>
</div>
<div class="col">
<table-order-component v-show="showOrder"
:orderID="props.orderID"
:id="props.id"></table-order-component>
</div>
</div>
</template>
</DefaultLayout>
</template>
When the page is loaded I am getting following error (warning):
[vite] connecting... client.ts:16:8
[vite] connected. client.ts:53:14
[Vue warn]: Invalid vnode type when creating vnode: .
at <DefaultLayout>
at <Tables onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< undefined > >
at <RouterView>
at <App> runtime-core.esm-bundler.js:38:16
[Vue warn]: Invalid vnode type when creating vnode: .
at <DefaultLayout>
at <Tables onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref<
Proxy { <target>: Proxy, <handler>: {…} }
> > at <RouterView> at <App> runtime-core.esm-bundler.js:38:16
What am I doing wrong here?
Default layout:
<script setup>
import AppHeader from '#/components/AppHeader.vue'
</script>
<template>
<AppHeader></AppHeader>
<div id="container-fluid">
<main>
<slot></slot>
</main>
</div>
</template>
App Header:
<script setup>
import { useRouter } from 'vue-router'
import {useMainStore} from "#/store/main.js";
const mainStore = useMainStore()
const router = useRouter()
const logout = () => {
mainStore.logout()
.then(() => {
router.push({
name: 'Login'
})
})
}
</script>
<template>
<nav id="nav">
<button #click="logout">Logout</button>
</nav>
</template>
<style>
</style>

Vuejs + onClick doesn't work on dynamic element loaded after mounted

I'm stucked with this issue. When I click on some element it push an item to an array, and I show this array in a table. I want to add an action to delete any row of the table on this way for example:
Table
My code:
<div id="pos">
<div class="container-fluid" style="font-size: 0.8em;">
<div class="row grid-columns">
<div class="col-md-6 col">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Descripcion</th>
<th>Stock</th>
<th>Precio uni</th>
<th>Precio alt</th>
<th>Cant</th>
<th>Subtotal</th>
<th>Acciones</th>
</tr>
</thead>
<tbody>
<pos-products
:products="products"
v-on:remove-product="removeProduct"
>
</pos-products>
<!-- <tr v-for="item in products" :key="item.id">
<th scope="row">${item.id}</th>
<td>${ item.descripcion }</td>
<td>${ item.stock }</td>
<td>${ item.precio } $</td>
<td>${ item.precio_alt } $</td>
<td>
<v-minusplusfield :value="1" :min="1" :max="100" v-model="item.cant"></v-minusplusfield>
</td>
<td>${ getSubtotal(item) }</td>
<td> Borrar </td>
</tr> -->
</tbody>
</table>
</div>
<div class="col-md-6 col">
<div>
<div id="grid-header" class="p-2 border-b ">
<input class="form-control" name="searchString" placeholder="Buscar producto" type="text" v-model="searchString" />
</div>
</div>
<div style="background-color:#fff">
<div class="col-md-3" v-for="item in searchResults">
<a
href="#"
class="list-group-item"
:key="item.id"
#click="loadItem(item)"
>
<img src="//images03.nicepage.com/a1389d7bc73adea1e1c1fb7e/af4ca43bd20b5a5fab9f188a/pexels-photo-3373725.jpeg" alt="" class="u-expanded-width u-image u-image-default u-image-1" width="25" height="30">
<h6 class="u-text u-text-default u-text-1">${item.descripcion}</h6>
<h4 class="u-text u-text-default u-text-2">${item.precio}$ / ${item.precio_alt}$</h4>
</a>
</div>
</div>
</div>
</div>
</div>
Vue code:
const app = new Vue({
el: "#pos",
delimiters: ["${", "}"],
data () {
return {
products: [],
total: 0,
client: "",
user: "",
paymentDetail: [],
errors: {},
garantia: false,
saveButton: false,
seller: "",
searchString: "",
searchTypingTimeout: "",
searchResults: [],
}
},
methods: {
getSubtotal: function (item) {
return parseInt(item.cant) * parseFloat(item.precio);
},
loadItem: function (item) {
this.products.push({
id: item.id,
descripcion: item.descripcion,
stock: item.stock,
precio: item.precio,
precio_alt: item.precio_alt,
cant: 1,
});
},
removeItem: () => {
products = products.filter((el) => el !== item);
},
searchProducts: function (value) {
axios
.post("/v2/producto/search", {
query: value
})
.then((response) => {
if (!response.status == 200 || response.data.error) {
console.log('error')
const errorMessage = response.data.error
? response.data.error
: "Ha ocurrido un error";
console.log("mensaje: " + errorMessage);
this.$swal({
icon: "error",
title: "Oops...",
text: errorMessage,
});
return;
}
this.searchResults = response.data.data;
})
.catch((error) => {
console.log("catch error", error);
});
},
},
mounted() {
var csrf = document
.querySelector('meta[name="csrf-token"]')
.getAttribute("content");
this.products = [];
},
computed: {},
watch: {
total(val) {
this.total = parseFloat(val);
},
searchString(val) {
if (this.searchTypingTimeout) clearTimeout(this.searchTypingTimeout);
this.searchTypingTimeout = setTimeout(
() => this.searchProducts(this.searchString),
850
);
},
},
});
I got this:
vue.js?3de6:634 [Vue warn]: Property or method "removeItem" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
Try using classic function like this :
removeItem(item){
const index = this.items.findIndex(x => x.id === item.id)
this.items.splice(index, 1)
},
I've here loaded the data with the jsonplaceholder.typicode.com api
new Vue({
el: '#app',
data: () => ({
items: []
}),
async mounted(){
await axios.get('https://jsonplaceholder.typicode.com/posts')
.then(res => {
this.items = res.data
})
},
methods: {
removeItem(item){
const index = this.items.findIndex(x => x.id === item.id)
this.items.splice(index, 1)
},
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.27.2/axios.min.js" integrity="sha512-odNmoc1XJy5x1TMVMdC7EMs3IVdItLPlCeL5vSUPN2llYKMJ2eByTTAIiiuqLg+GdNr9hF6z81p27DArRFKT7A==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<div id="app">
<h1>List </h1>
<ul>
<li v-for="item of items" :key="item.id">
<a #click="removeItem(item)">{{item.id}} - {{item.title}}</a>
</li>
</ul>
</div>

Vuejs 3 props are Proxy

I am passing array as a prop to another component, and when I want to read this on mounted in that component, I got Proxy {}. How to read data from this prop? You can see in example when I want to console log prop, result is Proxy {}. I can see all values in HTML structure, but not in the console on mounted.
<template>
<div class="custom-select-container">
<div class="selected-item" #click="openSelect">
<span class="selected-items-text">{{ selectedItem.name }}</span>
<span class="icon-arrow1_b selected-items-icon" :class="{ active: showOptions }" />
</div>
<transition name="fade">
<ul v-show="options.length && showOptions" class="custom-select-options">
<li v-for="(option, index) in options" :key="index" class="custom-select-item">{{ option.name }}</li>
</ul>
</transition>
</div>
</template>
<script>
import { ref, onMounted } from 'vue'
export default {
props: {
options: {
type: Array,
default: () => []
}
},
setup(props) {
let showOptions = ref(false);
let selectedItem = ref(props.options[0])
const openSelect = () => {
showOptions.value = !showOptions.value
}
onMounted(() => {
console.log('test', props.options)
})
return {
openSelect,
showOptions,
selectedItem
}
}
}
</script>
Parent component where I am passing data:
<template>
<div class="page-container">
<div>
<div class="items-title">
<h3>List of categories</h3>
<span>({{ allCategories.length }})</span>
</div>
<div class="items-container">
<div class="item" v-for="(category, index) in allCategories" :key="index">
<span class="item-cell size-xs">{{ index + 1 }}.</span>
<span class="item-cell size-l">{{ category.name }}</span>
</div>
</div>
</div>
<custom-select
:options="allCategories"
/>
</div>
</template>
<script>
import CustomSelect from '../components/Input/CustomSelect'
import { computed } from 'vue'
import { useStore } from 'vuex'
export default {
components: {
CustomSelect
},
computed: {
},
setup() {
const store = useStore()
const allCategories = computed(() => store.getters['categories/getAllCategories'])
return {
allCategories
}
}
}
</script>
That's how reactivity works in Vue3.
use
console.log(JSON.parse(JSON.stringify(data))
or
console.log(JSON.stringify(data, null, 2))
to show the content of proxies in console

VueJs // V-for with v-modal // Data update issue after button clicked

UPDATED!!! Full component's code added:
I've inputs rendered via v-for loop. List of inputs depends on an API response. I need a "plus" and "minus" buttons to change input's value. I almost find a solution but value changes only on sibling input change but not on button click.
Here is my code...
<template>
<div class="allPlaces" id="allPlaces">
<div class="wiget__row wiget__row--top" id="topRow">
<div class="wiget__details wiget__details--allPlaces">
<div class="wiget__logo">
<img class="wiget__img wiget__img--logo" width="28" height="30" src="../../img/kassy_logo_img.png" alt="">
<img class="wiget__img wiget__img--logoTXT" width="59" height="28" src="../../img/kassy_logo_text.png" alt="">
</div>
<div class="wiget__eventDetails">
<p class="wiget__eventName">{{this.show[0].title}}</p>
<div class="wiget__place">
<span class="wiget__venue">{{this.building[0].title}}, </span>
<span class="wiget__venueHall">{{this.hall[0].title}}</span>
</div>
<div class="wiget__dateOfEvent">
<span class="wiget__time">{{this.getTime(this.event[0].date)}}</span>
<span class="wiget__date">{{this.getDate(this.event[0].date)}}</span>
</div>
</div>
</div>
</div>
<div class="allPlaces__wrapper">
<h1 class="allPlaces__title">Оформление заказа</h1>
<p class="allPlaces__description">Для оформления заказа выберите нужное количество мест</p>
<div class="allPlaces__content">
<div class="allPlaces__entrance" v-for="(entrance, index) in places.entrance" :key="entrance.id">
<div class="allPlaces__infoBlock">
<div>
<div class="allPlaces__available">
<span class="allPlaces__label allPlaces__label--places">Доступно мест:</span>
<span class="allPlaces__data">&nbsp{{entrance.vacant_places}}</span>
</div>
<div class="allPlaces__title allPlaces__title--entrance">{{getEntranceName(entrance)}}</div>
</div>
<div class="allPlaces__price">
<span class="allPlaces__label">Цена: </span>
<span class="allPlaces__data">{{entrance.price}}</span>
</div>
</div>
<div class="allPlaces__orderBlock">
<div class="allPlaces__inputBlock">
<input class="allPlaces__input" type="number" name="amount" v-bind:id="tickets"
v-model="tickets[index]" #blur="showLabel($event, index)">
<label class="allPlaces__label allPlaces__label--input"
#click="hideLabel($event, index)">Количество мест
</label>
</div>
<div class="allPlaces__btnBlock">
<button class="allPlaces__btn allPlaces__btn--minus" type="button" name="button"
#click="removeTicket(index)"></button>
<button class="allPlaces__btn allPlaces__btn--plus" type="button" name="button"
#click="addTicket(index)">
</button>
</div>
<button class="allPlaces__btn allPlaces__btn--confirm" type="button" name="button"
#click="addEntrancePlaceToCart(entrance, index)">
<img class="allPlaces__img allPlaces__img--cart" src="../../img/cartWhite.png" alt="Корзина">
<span class="allPlaces__text allPlaces__text--cart">В корзину</span>
</button>
</div>
</div>
</div>
</div>
<div class="wiget__row wiget__row--bottom" id="bottomRow">
<div class="wiget__row">
<div class="wiget__amountBlock">
<span class="wiget__tickets">
<span>Билеты:</span>
<span class="wiget__amount wiget__amount--tickets">{{this.ticketsInCart.count}}</span>
<span>шт.</span>
</span>
<div class="wiget__money">
<span class="wiget__money wiget__money--label">Итого:</span>
<p>
<span class="wiget__amount wiget__amount--money">{{this.ticketsInCart.total}}&nbsp</span>
<span class="wiget__amount wiget__amount--money">руб.</span>
</p>
</div>
</div>
<div class="wiget__btnBlock">
<button class="wiget__btn wiget__btn--goToHall" type="button" name="button"
#click="goToHall()">
Выбрать на схеме
</button>
<button class="wiget__btn wiget__btn--confirm" type="button" name="button"
#click="goToCartPage($event)">Оформить заказ</button>
</div>
</div>
<div class="wiget__row wiget__row--service">
<span class="wiget__service">Сервис предоставлен:</span>
Kassy.ru
</div>
</div>
</div>
</template>
<script>
import vueMethods from '../../mixins/methods'
import { mapState } from 'vuex'
export default {
name: 'allPlaces',
mixins: [vueMethods],
data () {
return {
tickets: []
}
},
mounted () {
this.$nextTick(function () {
window.addEventListener('resize', this.updateAllPlacesOnResize)
this.setupAllPlaces()
})
},
methods: {
setupAllPlaces () {
let allPlaces = document.getElementById('allPlaces')
let topRow = document.querySelector('.wiget__row--top')
let wrapper = document.querySelector('.allPlaces__wrapper')
let bottomRow = document.querySelector('.wiget__row--bottom')
let allPlacesHeight = allPlaces.clientHeight
let topRowHeight = topRow.clientHeight
let bottomRowHeight = bottomRow.clientHeight
let wrapperHeight = allPlacesHeight - topRowHeight - bottomRowHeight
console.log('topRowHeight ', topRowHeight)
console.log('allPlacesHeight ', allPlacesHeight)
console.log('bottomRowHeight ', bottomRowHeight)
console.log('wrapperHeight ', wrapperHeight)
wrapper.style.minHeight = wrapperHeight + 'px'
},
updateAllPlacesOnResize (event) {
this.setupAllPlaces()
},
getEntranceName (entrance) {
let sectionId = entrance.section_id
let section = this.section
let sectionName = section.filter(function (e) {
return e.id === sectionId
})
return sectionName[0].title
},
addTicket (index) {
console.log(this.tickets)
console.log(this.tickets[index])
this.tickets[index] = parseInt(this.tickets[index]) + 1
return this.tickets
},
removeTicket (index) {
this.tickets[index] = parseInt(this.tickets[index]) - 1
},
addEntrancePlaceToCart (entrance, index) {
console.log('entrance.id to add to cart ', entrance.id)
let db = this.db
let places = parseInt(this.tickets[index])
console.log('places ', places)
console.log('index ', index)
let sessionId = this.sessionId
let entranceId = parseInt(entrance.id)
let params = {db, places, sessionId, entranceId}
this.$store.dispatch('addEntrancePlaceToCart', params) // Добавили место в корзину
},
goToHall () {
this.$store.dispatch('closeAllPlaces')
this.$store.dispatch('openHallPlan')
},
hideLabel (e, index) {
console.log('CLICKED')
console.log('index click', index)
let input = document.getElementsByClassName('allPlaces__input')
let target = e.target
input[index].focus()
console.log('this.tickets ', this.tickets)
console.log(target)
if (this.tickets === '') {
target.style.display = 'block'
} else {
target.style.display = 'none'
}
},
showLabel (e, index) {
console.log('BLUR')
console.log('index blur', index)
let label = document.getElementsByClassName('allPlaces__label allPlaces__label--input')
console.log(this.tickets[index])
if (this.tickets[index] === '' || this.tickets[index] === undefined) {
label[index].style.display = 'block'
} else {
label[index].style.display = 'none'
}
}
},
destroyed () {
window.removeEventListener('resize', this.setupAllPlaces)
},
computed: {
...mapState({
db: state => state.onload.currentDb,
currentEvent: state => state.onload.currentEvent,
modals: state => state.modals,
metric: state => state.onload.eventData.metric,
section: state => state.onload.eventData.section,
show: state => state.onload.eventData.show,
event: state => state.onload.eventData.event,
building: state => state.onload.eventData.building,
hall: state => state.onload.eventData.hall,
places: state => state.onload.eventData.places,
placesSeated: state => state.onload.eventData.places.place,
sessionId: state => state.cart.sessionId,
ticketsInCart: state => state.cart.ticketsInCart
})
}
}
</script>
<style scoped lang="stylus">
#import '../../styles/Root/allPlaces'
#import '../../styles/Root/wiget'
</style>
Please advise
You tickets is not correctly initialized. The data populated a empty array but the template will add new element without using the VueJs way of adding reactivity.
What happen is similare to:
let tickets = [];
tickets[0] = ...;
In VueJs you should use push to insert an element to an array and not using the "sparse implementation".
So when your places is being populated inside your store you should create the tickets table from the size of it. Something similare to the following in a watcher or elsewhere depending on your need:
this.tickets = this.place.map(_ => 0);