I am looking to dynamically create a list of actions, each of which is a component, based on a condition where the object variable store.plan
is not empty. I attempted using v-if
, which worked well for rendering but not for creating the component.
However, I encountered an error:
Uncaught (in promise) TypeError: action is undefined
You can find the complete code of this component here.
Could you please guide me on how to solve this issue? Thank you in advance.
<template>
<div class="planlist" v-if="parse">
<ul id="planOl">
<Action
v-for="action in store.plan"
:action_id="action.act_id"
:actor="action.actor"
:color="action.color"
:size="action.size"
:lego_name="action.lego"
:pick_pos="action.pick"
:place_pos="action.place"
:blocked="action.blocked"
:status="action.status"
:key="action.act_id"
/>
</ul>
</div>
</template>
<script>
import Action from '../components/Action.vue';
import { store } from '../js/store.js'
export default {
name: 'Plan',
data() {
return {
store,
}
},
computed: {
parse() {
if (store.plan.length > 0) {
return true;
}
return false;
}
},
components: {Action}
}
</script>