Vue2.0实战
2017-12-18 09:44
323 查看
<div class="yo-flex" id="app"> <header class="yo-header lh-header"> <h2 class="title">选择车型</h2> <a href="javaScript:history.go(-1);" class="regret yo-ico"> </a> </header> <div class="flex" @click="closeDetails"> <!--热门车型区--> <section class="hot-box"> <h4 class="title">热门车型</h4> <ul class="hot-list" v-cloak> <li class="hot-item" v-for="item in hotList"> <img :src="item.imgSrc" alt="车标"> <span>{{item.title}}</span> </li> </ul> </section> <!--车型列表区--> <ul class="total-list" v-cloak> <li class="total-item" v-for="item in typeList"> <h4 class="title">{{item.letter}}</h4> <ul class="car-list"> <li v-for="(carItem,index) in item.carList" @click.stop="checkType(index,item.carList)"> {{carItem.carName}} </li> </ul> </li> </ul> <!--车型字母表--> <div class="letter-box" v-cloak> <ul class="letter-list"> <li v-for="item in typeList">{{item.letter}}</li> </ul> </div> <ul class="car-type-list" v-show="showDetails" v-cloak> <li class="type-item" :class="{checked: detailActive == index}" v-for="(item,index) in detailsList" @click.stop="checkDetails(index)"><span>{{item}}</span></li> </ul> </div> </div>
var vm = new Vue({ el: '#app', data: { showDetails: false, hotList: [ { title: '大众', imgSrc: 'images/car/dazong.png' }, { title: '大众', imgSrc: 'images/car/dazong.png' }, { title: '大众', imgSrc: 'images/car/dazong.png' }, { title: '大众', imgSrc: 'images/car/dazong.png' }, { title: '大众', imgSrc: 'images/car/dazong.png' }, { title: '大众', imgSrc: 'images/car/dazong.png' }, { title: '大众', imgSrc: 'images/car/dazong.png' }, { title: '大众', imgSrc: 'images/car/dazong.png' } ], typeList: [ { letter: 'A', carList: [ { carName: '奥迪', carType: ['A4','A4(进口)','A4L','A5','A6','A7','A8'] }, { carName: '阿斯顿·马丁', carType: ['M4','M4(进口)','M5','M6','M7','M8'] } ] }, { letter: 'B', carList: [ { carName: '别克', carType: ['B4','B4(进口)','A4L','A5','A6','A7','A8'] }, { carName: '保时捷', carType: ['BS4','A4(进口)','A4L','A5','A6'] } ] }, { letter: 'D', carList: [ { carName: '大众', carType: ['D4','A4(进口)','A4L','A5'] } ] }, { letter: 'F', carList: [ { carName: '丰田', carType: ['F4','F4(进口)','A4L'] } ] } ], detailActive: -1, detailsList: [] }, methods: { checkType(index,arr) { this.detailActive = -1; this.detailsList = arr[index].carType; this.showDetails = true; }, checkDetails(index){ this.detailActive = index; }, closeDetails(){ this.showDetails = false; } } })
相关文章推荐
- vue2.0构建单页应用最佳实战
- 【Vue2.0】 项目实战案例及Demo,基于vue2.0+vuex+vue-router2+axios实现
- vue2.0项目实战(5)vuex快速入门
- vue(2.0)+vue-router(2.0)+vuex(2.0)实战
- 前后端分离之vue2.0+webpack2 实战项目 -- webpack介绍
- 【vue2.0实战分享】搭建vue运行环境以及项目目录
- Vue 2.0 构建单页应用最佳实战
- Vue2.0 项目实战案例及Demo,基于vue2.0+vuex+vue-router+axios实现
- Vue 2.0 构建单页应用最佳实战
- 前后端分离之vue2.0+webpack2 实战项目 -- html模板拼接
- Vue 2.0 真实点餐项目实战
- vue2.0构建单页应用最佳实战案例 vue.js
- 最新vue2.0高级实战教程商城前端 node.js后端实战视频教程
- vue2.0实战案例之高级教程-老孟编程
- Vue2.0项目实战语法
- Vue 2.0 实战之仿Eleme WebApp SPA(学习)
- vue2.0构建单页应用最佳实战
- 前后端分离之vue2.0+webpack2 实战项目 -- webpack介绍
- vue2.0实战之基础入门(1)
- vue2.0构建单页应用最佳实战 (一)