1.debugger--断点哪里需要在哪里写
2.
emit-value:select下拉框选中显示的是options的value map-options: select下拉框选中显示的是options的lable
3.实现tabs点击切换内容
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | <div style="max-width: 600px"> <q-tabs v-model="tab" @input="tb" align="justify" narrow-indicator class="q-mb-lg" > <q-tab class="text-purple" name="mails" label="全部商品" icon="whatshot" /> <q-tab class="text-orange" name="alarms" label="居家装饰" icon="spa" /> <q-tab class="text-teal" name="movies" label="服装配饰" icon="local_dining" /> <q-tab class="text-orange" name="digital" label="数码家电" icon="devices_other" /> <q-tab class="text-teal" name="food" label="食品生鲜" icon="whatshot" /> </q-tabs> <div class="q-gutter-y-sm"> <q-tab-panels v-model="tab" animated transition-prev="scale" transition-next="scale" > <q-tab-panel name="mails"> <div id="goodList" class="text-dark"> <div id="items" class="q-gutter-y-md column"> <q-card class="my-card" v-for="(item, i) in items" :key="i"> <q-img :src="item.image" height="200px" /> <q-card-section> <q-btn fab color="primary" icon="add" class="absolute" label="加入兑换清单" style="top: 0; right: 12px; transform: translateY(-50%);" @click="addToCart(item.id)" ></q-btn> <div class="row no-wrap items-center"> <div class="col text-h6 ellipsis"> {{ item.storeName }} </div> <div class="col-auto text-grey text-caption q-pt-md row no-wrap items-center" > <q-icon name="stock" /> 还剩 {{ item.stock }} 份 </div> </div> </q-card-section> <q-card-section class="q-pt-none"> <div class="text-subtitle1">{{ item.otPrice }} 积分</div> <div class="text-caption text-grey"> {{ item.storeInfo }} </div> </q-card-section> </q-card> </div> </div> </q-tab-panel> <q-tab-panel name="alarms"> <div id="goodList" class="text-dark"> <div id="items" class="q-gutter-y-md column"> <q-card class="my-card" v-for="(item, i) in items" :key="i"> <q-img :src="item.image" height="200px" /> <q-card-section> <q-btn fab color="primary" icon="add" class="absolute" label="加入兑换清单" style="top: 0; right: 12px; transform: translateY(-50%);" v-model="item.id" @click="addToCart(item.id)" /> <div class="row no-wrap items-center"> <div class="col text-h6 ellipsis"> {{ item.storeName }} </div> <div class="col-auto text-grey text-caption q-pt-md row no-wrap items-center" > <q-icon name="stock" /> 还剩 {{ item.stock }} 份 </div> </div> </q-card-section> <q-card-section class="q-pt-none"> <div class="text-subtitle1">{{ item.otPrice }} 积分</div> <div class="text-caption text-grey"> {{ item.storeInfo }} </div> </q-card-section> </q-card> </div> </div> </q-tab-panel> <q-tab-panel name="movies"> <div id="goodList" class="text-dark"> <div id="items" class="q-gutter-y-md column"> <q-card class="my-card" v-for="(item, i) in items" :key="i"> <q-img :src="item.image" height="200px" /> <q-card-section> <q-btn fab color="primary" icon="add" class="absolute" label="加入兑换清单" style="top: 0; right: 12px; transform: translateY(-50%);" v-model="item.id" @click="addToCart(item.id)" /> <div class="row no-wrap items-center"> <div class="col text-h6 ellipsis"> {{ item.storeName }} </div> <div class="col-auto text-grey text-caption q-pt-md row no-wrap items-center" > <q-icon name="stock" /> 还剩 {{ item.stock }} 份 </div> </div> </q-card-section> <q-card-section class="q-pt-none"> <div class="text-subtitle1">{{ item.otPrice }} 积分</div> <div class="text-caption text-grey"> {{ item.storeInfo }} </div> </q-card-section> </q-card> </div> </div> </q-tab-panel> <q-tab-panel name="digital"> <div id="goodList" class="text-dark"> <div id="items" class="q-gutter-y-md column"> <q-card class="my-card" v-for="(item, i) in items" :key="i"> <q-img :src="item.image" height="200px" /> <q-card-section> <q-btn fab color="primary" icon="add" class="absolute" label="加入兑换清单" style="top: 0; right: 12px; transform: translateY(-50%);" v-model="item.id" @click="addToCart(item.id)" /> <div class="row no-wrap items-center"> <div class="col text-h6 ellipsis"> {{ item.storeName }} </div> <div class="col-auto text-grey text-caption q-pt-md row no-wrap items-center" > <q-icon name="stock" /> 还剩 {{ item.stock }} 份 </div> </div> </q-card-section> <q-card-section class="q-pt-none"> <div class="text-subtitle1">{{ item.otPrice }} 积分</div> <div class="text-caption text-grey"> {{ item.storeInfo }} </div> </q-card-section> </q-card> </div> </div> </q-tab-panel> <q-tab-panel name="food"> <div id="goodList" class="text-dark"> <div id="items" class="q-gutter-y-md column"> <q-card class="my-card" v-for="(item, i) in items" :key="i"> <q-img :src="item.image" height="200px" /> <q-card-section> <q-btn fab color="primary" icon="add" class="absolute" label="加入兑换清单" style="top: 0; right: 12px; transform: translateY(-50%);" v-model="item.id" @click="addToCart(item.id)" /> <div class="row no-wrap items-center"> <div class="col text-h6 ellipsis"> {{ item.storeName }} </div> <div class="col-auto text-grey text-caption q-pt-md row no-wrap items-center" > <q-icon name="stock" /> 还剩 {{ item.stock }} 份 </div> </div> </q-card-section> <q-card-section class="q-pt-none"> <div class="text-subtitle1">{{ item.otPrice }} 积分</div> <div class="text-caption text-grey"> {{ item.storeInfo }} </div> </q-card-section> </q-card> </div> </div> </q-tab-panel> </q-tab-panels> </div> </div> <script> export default { data () { return { tab: 'mails', items: [], } }, methods: { tb() { this.$axios({ method: 'get', url: 'http://localhost:8000/api/category', // tab的接口 headers: { 'Authorization': window.sessionStorage.getItem("token") }, }) .then(res => { this.items = res.data.data console.log(res.data.data) console.log(res) this.$axios({ method: 'get', url: 'http://localhost:8000/api/products', //tab的切换框内容接口 headers: { 'Authorization': window.sessionStorage.getItem("token") }, }) .then(res => { this.items = res.data.data console.log(res.data.data) console.log(res) }) .catch(function (error) { console.log(error) }) }) .catch(function (error) { console.log(error) }) }, } } </script> |
- 因为
写了五个,所以下方的 也需要写五个,因为 与 是一一对应的关系,否则就 就不写,直接axios获取,下方的 也是同 一样。 - @input用法同@click相同,(Emitted when the component changes the model; This event isn't fired if the model is changed externally; Is also used by v-model:当组件更改模型时发出;如果模型在外部发生更改,则触发此事件;也被v模型使用),这是
的event事件