v-for.uvue 916 字节
Newer Older
Y
yurj26 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
<template>
  <view class="page">
    <view class="split-title">list items</view>
    <view v-for="item in items">
      <view class="list-item">{{ item.text }}</view>
    </view>

    <view class="split-title">number</view>
    <view v-for="(_, index) in 8" :key="index">
      <view class="map-number-1">{{ index }}</view>
    </view>

    <view class="split-title">object</view>
    <view v-for="(value, key) in object">
      key: {{ key }} value: {{ value }}
    </view>
  </view>
</template>

<script>
  type ListItem = {
    text : string
  }
  type MyObject = {
    key1 : string
    key2 : string
    key3 : string
  }
  export default {
    data() {
      return {
        items: [{ text: 'Foo1' }, { text: 'Foo2' }, { text: 'Foo3' }] as ListItem[],
        object: { key1: 'Foo1', key2: 'Foo2', key3: 'Foo3' } as MyObject
      }
    }
  }
</script>

<style>
</style>