订单分类和评分--vue.js学习笔记2
生活随笔
收集整理的這篇文章主要介紹了
订单分类和评分--vue.js学习笔记2
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
效果圖:
1、訂單分類
<template><div class="hello"><h1>{{ msg }}</h1><div class="cak-order"><ul class="cak-menu"><li v-for="(item,index) in menu" :class="{on:index==active}" @click="switchItem(item,index)">{{ item.text }}</li></ul><p v-for="(item,index) in alllist">商品名:{{ item.text }}、價格:{{ item.money }}、數量:{{ item.num }}、狀態:{{ item.status }}</p></div><Evaluate></Evaluate></div> </template><script>import Evaluate from '@/components/Evaluate'export default {name: 'HelloWorld',data () {return {msg: 'vue-order',active:0,menu:[{text:'全部訂單'},{text:'代付款'},{text:'待發貨'},{text:'待收貨'},{text:'待評價'}],alllist:[],//全部訂單pay:[], //代付款send:[], //代發貨collect:[], //待收貨evaluate:[], //待評價 lists:[{text:'商品1',money:4,num:4,status:0}, //status 0 待付款,1待發貨,2待收貨,3待評價{text:'商品2',money:3,num:1,status:1},{text:'商品3',money:4,num:2,status:2},{text:'商品4',money:7,num:6,status:0},{text:'商品4',money:7,num:6,status:3},{text:'商品4',money:7,num:6,status:0},{text:'商品4',money:7,num:6,status:3},{text:'商品3',money:4,num:2,status:2},{text:'商品3',money:4,num:2,status:2},{text:'商品4',money:7,num:6,status:3},]}},components: {Evaluate},created(){// 加載全部訂單this.alllist = this.listsfor(var i =0;i<this.lists.length;i++){//代付款if(this.lists[i].status == 0){this.pay.push(this.lists[i])}//代發貨else if(this.lists[i].status == 1){this.send.push(this.lists[i])}//待收貨else if(this.lists[i].status == 2){this.collect.push(this.lists[i])}//待評價else if(this.lists[i].status == 3){this.evaluate.push(this.lists[i])}} },methods: {switchItem(item,index){this.active = indexswitch(index){case 0:this.alllist = this.listsconsole.log("全部訂單")break;case 1:this.alllist = this.payconsole.log("代付款")break;case 2:this.alllist = this.sendconsole.log("待發貨")break;case 3:this.alllist = this.collectconsole.log("待收貨")break;case 4:this.alllist = this.evaluateconsole.log("待評價")break; }}} } </script><!-- Add "scoped" attribute to limit CSS to this component only --> <style scoped> h1, h2 {font-weight: normal; }ul {list-style-type: none;padding: 0; }li {display: inline-block;margin: 0 10px; }a {color: #42b983; } .cak-menu li{background-color: #eee;padding: 5px 10px;cursor:pointer; } .cak-menu li.on{color:#fff;background-color: pink; } </style>2、評分
<template><ul><li v-for="(name, index) in list"><div class="score"><span>{{name}}:</span><i v-for="($item,$index) in 5" @click="washingCarScore(index,$index)" :class="{full:$index<=saveIndex[index]}"></i><span>{{num[index]}}分</span></div></li></ul> </template> <script>export default {data() {return{saveIndex: [-1, -1, -1],list: ['商品','物流','客服'],num: [0, 0, 0],}},methods:{washingCarScore(type, index){this.$set(this.saveIndex, type, index)this.$set(this.num, type, index+1)// $set(target,key,value) target:對象、數組; key:數組中第幾個值; value:key改變的值==》 刪除數組target中第key個值,添加新的value來代替/*console.log(this.saveIndex)console.log(this.num)*/}}} </script> <style>.score i{display: inline-block;width: 24px;height: 24px; background: url(../../static/img/start-default.png); /*初始圖片*/ background-size: 100%; } .score .full{background-image: url(../../static/img/start-full.png);} /*active圖片*/ </style>?
轉載于:https://www.cnblogs.com/CaktyRiven/p/8274758.html
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的订单分类和评分--vue.js学习笔记2的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 075-SSH遇到不能登陆的情况
- 下一篇: fsLayui缓存使用