Place a div with a directive v-forwithin the scope <template>that checks menufor v-if:
<template v-if="menu">
<div v-for="item in menu.items">{{ item.text }}</div>
</template>
Thus, the div inside the template will not be displayed if it menudoes not exist.
If you really need a check inside the statement v-foras you try, it will look like this:
<div v-for="item in (menu ? menu.items : [])">{{ item.text }}</div>
source
share