要求一 请通过v-for指令将数组["周一","周二","周三","周四","周五","周六"]渲染到页面上,分别包含值和下标, 要求二 请配合v-if指令使用,让h1把周一包裹,h2把周二包裹,......,h6把周六包裹
时间: 2023-09-18 21:10:06 浏览: 58
创建一维数组变量-matlab教程
<template>
<div>
<h1 v-if="index === 0" v-for="(day, index) in days" :key="index">{{ day }} - {{ index }}</h1>
<h2 v-if="index === 1" v-for="(day, index) in days" :key="index">{{ day }} - {{ index }}</h2>
<h3 v-if="index === 2" v-for="(day, index) in days" :key="index">{{ day }} - {{ index }}</h3>
<h4 v-if="index === 3" v-for="(day, index) in days" :key="index">{{ day }} - {{ index }}</h4>
<h5 v-if="index === 4" v-for="(day, index) in days" :key="index">{{ day }} - {{ index }}</h5>
<h6 v-if="index === 5" v-for="(day, index) in days" :key="index">{{ day }} - {{ index }}</h6>
</div>
</template>
<script>
export default {
data() {
return {
days: ["周一","周二","周三","周四","周五","周六"]
}
}
}
</script>
阅读全文