|
| 1 | +<template> |
| 2 | + <div class="q-pa-md"> |
| 3 | + <q-toggle v-model="loading" label="Loading state" class="q-mb-md" /> |
| 4 | + <q-table |
| 5 | + title="Treats" |
| 6 | + :data="data" |
| 7 | + :columns="columns" |
| 8 | + color="primary" |
| 9 | + row-key="name" |
| 10 | + :loading="loading" |
| 11 | + > |
| 12 | + <template v-slot:loading> |
| 13 | + <q-inner-loading showing color="primary" /> |
| 14 | + </template> |
| 15 | + </q-table> |
| 16 | + </div> |
| 17 | +</template> |
| 18 | + |
| 19 | +<script> |
| 20 | +export default { |
| 21 | + data () { |
| 22 | + return { |
| 23 | + loading: false, |
| 24 | +
|
| 25 | + columns: [ |
| 26 | + { |
| 27 | + name: 'desc', |
| 28 | + required: true, |
| 29 | + label: 'Dessert (100g serving)', |
| 30 | + align: 'left', |
| 31 | + field: row => row.name, |
| 32 | + format: val => `${val}`, |
| 33 | + sortable: true |
| 34 | + }, |
| 35 | + { name: 'calories', align: 'center', label: 'Calories', field: 'calories', sortable: true }, |
| 36 | + { name: 'fat', label: 'Fat (g)', field: 'fat', sortable: true }, |
| 37 | + { name: 'carbs', label: 'Carbs (g)', field: 'carbs' }, |
| 38 | + { name: 'protein', label: 'Protein (g)', field: 'protein' }, |
| 39 | + { name: 'sodium', label: 'Sodium (mg)', field: 'sodium' }, |
| 40 | + { name: 'calcium', label: 'Calcium (%)', field: 'calcium', sortable: true, sort: (a, b) => parseInt(a, 10) - parseInt(b, 10) }, |
| 41 | + { name: 'iron', label: 'Iron (%)', field: 'iron', sortable: true, sort: (a, b) => parseInt(a, 10) - parseInt(b, 10) } |
| 42 | + ], |
| 43 | + data: [ |
| 44 | + { |
| 45 | + name: 'Frozen Yogurt', |
| 46 | + calories: 159, |
| 47 | + fat: 6.0, |
| 48 | + carbs: 24, |
| 49 | + protein: 4.0, |
| 50 | + sodium: 87, |
| 51 | + calcium: '14%', |
| 52 | + iron: '1%' |
| 53 | + }, |
| 54 | + { |
| 55 | + name: 'Ice cream sandwich', |
| 56 | + calories: 237, |
| 57 | + fat: 9.0, |
| 58 | + carbs: 37, |
| 59 | + protein: 4.3, |
| 60 | + sodium: 129, |
| 61 | + calcium: '8%', |
| 62 | + iron: '1%' |
| 63 | + }, |
| 64 | + { |
| 65 | + name: 'Eclair', |
| 66 | + calories: 262, |
| 67 | + fat: 16.0, |
| 68 | + carbs: 23, |
| 69 | + protein: 6.0, |
| 70 | + sodium: 337, |
| 71 | + calcium: '6%', |
| 72 | + iron: '7%' |
| 73 | + }, |
| 74 | + { |
| 75 | + name: 'Cupcake', |
| 76 | + calories: 305, |
| 77 | + fat: 3.7, |
| 78 | + carbs: 67, |
| 79 | + protein: 4.3, |
| 80 | + sodium: 413, |
| 81 | + calcium: '3%', |
| 82 | + iron: '8%' |
| 83 | + }, |
| 84 | + { |
| 85 | + name: 'Gingerbread', |
| 86 | + calories: 356, |
| 87 | + fat: 16.0, |
| 88 | + carbs: 49, |
| 89 | + protein: 3.9, |
| 90 | + sodium: 327, |
| 91 | + calcium: '7%', |
| 92 | + iron: '16%' |
| 93 | + }, |
| 94 | + { |
| 95 | + name: 'Jelly bean', |
| 96 | + calories: 375, |
| 97 | + fat: 0.0, |
| 98 | + carbs: 94, |
| 99 | + protein: 0.0, |
| 100 | + sodium: 50, |
| 101 | + calcium: '0%', |
| 102 | + iron: '0%' |
| 103 | + }, |
| 104 | + { |
| 105 | + name: 'Lollipop', |
| 106 | + calories: 392, |
| 107 | + fat: 0.2, |
| 108 | + carbs: 98, |
| 109 | + protein: 0, |
| 110 | + sodium: 38, |
| 111 | + calcium: '0%', |
| 112 | + iron: '2%' |
| 113 | + }, |
| 114 | + { |
| 115 | + name: 'Honeycomb', |
| 116 | + calories: 408, |
| 117 | + fat: 3.2, |
| 118 | + carbs: 87, |
| 119 | + protein: 6.5, |
| 120 | + sodium: 562, |
| 121 | + calcium: '0%', |
| 122 | + iron: '45%' |
| 123 | + }, |
| 124 | + { |
| 125 | + name: 'Donut', |
| 126 | + calories: 452, |
| 127 | + fat: 25.0, |
| 128 | + carbs: 51, |
| 129 | + protein: 4.9, |
| 130 | + sodium: 326, |
| 131 | + calcium: '2%', |
| 132 | + iron: '22%' |
| 133 | + }, |
| 134 | + { |
| 135 | + name: 'KitKat', |
| 136 | + calories: 518, |
| 137 | + fat: 26.0, |
| 138 | + carbs: 65, |
| 139 | + protein: 7, |
| 140 | + sodium: 54, |
| 141 | + calcium: '12%', |
| 142 | + iron: '6%' |
| 143 | + } |
| 144 | + ] |
| 145 | + } |
| 146 | + } |
| 147 | +} |
| 148 | +</script> |
0 commit comments