v-for.uvue 823 字节
Newer Older
H
init.  
hdx 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
<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 style="color: red" v-for="(_, index) in 8" :key="index">
      <view class="map-number-1">{{ index }}</view>
    </view>

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

H
hdx 已提交
21
<script>
H
init.  
hdx 已提交
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
  type ListItem = {
    text : string
  }
  export default {
    data() {
      return {
        items: [{ text: 'Foo1' }, { text: 'Foo2' }, { text: 'Foo3' }] as ListItem[],
        object: { key1: 'Foo1', key2: 'Foo2', key3: 'Foo3' }
      }
    }
  }
</script>

<style>
</style>