1 回答

TA貢獻(xiàn)1862條經(jīng)驗(yàn) 獲得超6個(gè)贊
您好,歡迎來到 Stack Overflow!您的messageArray 使用 正確映射mapGetters,但是當(dāng)您使用 將其放入模板中時(shí),您將其展平為字符串{{message}},因?yàn)槟0宀逯颠壿媽ο筠D(zhuǎn)換為字符串,與Array.toString本例中的調(diào)用相同。你需要迭代它,即使用v-for指令:
<template>
<body>
<div class="container">
<h1 v-show="elementVisible" class="info">
<span v-for="m of message" :key="m">{{m}}</span>
</h1>
</div>
</body>
</template>
當(dāng)然,如果你只需要第一項(xiàng),你可以直接使用:
<template>
<body>
<div class="container">
<h1 v-show="elementVisible" class="info">{{message[0] || 'No message'}}</h1>
</div>
</body>
</template>
添加回答
舉報(bào)