vue遍历时添加个数过滤条件

1、效果

本身有5个地址,显示3个

2、address.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta charset="utf-8">
    <!-- Always force latest IE rendering engine or request Chrome Frame -->
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <title>Checkout - Confirm Address</title>
    <link href="css/base2.css" rel="stylesheet" >
    <link href="css/checkout.css" rel="stylesheet" >
</head>
<body class="checkout">
    <svg style="position: absolute; width: 0; height: 0; overflow: hidden;" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
        <defs>
            <symbol id="icon-add" viewBox="0 0 32 32">
                <title>add2</title>
                <path class="path1" d="M15 17h-13.664c-0.554 0-1.002-0.446-1.002-1 0-0.552 0.452-1 1.002-1h13.664v-13.664c0-0.554 0.446-1.002 1-1.002 0.552 0 1 0.452 1 1.002v13.664h13.664c0.554 0 1.002 0.446 1.002 1 0 0.552-0.452 1-1.002 1h-13.664v13.664c0 0.554-0.446 1.002-1 1.002-0.552 0-1-0.452-1-1.002v-13.664z"></path>
            </symbol>
            <symbol id="icon-ok" viewBox="0 0 39 32">
                <title>ok</title>
                <path class="path1" d="M14.084 20.656l-7.845-9.282c-1.288-1.482-3.534-1.639-5.016-0.351s-1.639 3.534-0.351 5.016l10.697 12.306c1.451 1.669 4.057 1.623 5.448-0.096l18.168-22.456c1.235-1.527 0.999-3.765-0.528-5.001s-3.765-0.999-5.001 0.528l-15.573 19.337z"></path>
            </symbol>
            <symbol id="icon-edit" viewBox="0 0 32 32">
                <title>edit</title>
                <path class="path1" d="M25.599 11.292l-4.892-4.892 3.825-3.825 4.892 4.892-3.825 3.825zM4.732 23.308l3.959 3.959-5.939 1.98 1.98-5.939zM10.666 26.225l-4.892-4.892 13.425-13.425 4.892 4.892-13.425 13.425zM31.687 6.713l-6.4-6.4c-0.417-0.417-1.091-0.417-1.508 0l-20.267 20.267c-0.114 0.115-0.191 0.25-0.242 0.393-0.003 0.009-0.012 0.015-0.015 0.025l-3.2 9.6c-0.128 0.383-0.029 0.806 0.257 1.091 0.203 0.204 0.476 0.313 0.754 0.313 0.112 0 0.227-0.017 0.337-0.054l9.6-3.2c0.011-0.003 0.017-0.013 0.027-0.016 0.142-0.052 0.276-0.128 0.39-0.242l20.267-20.267c0.417-0.416 0.417-1.091 0-1.508v0z"></path>
            </symbol>
            <symbol id="icon-del" viewBox="0 0 26 32">
                <title>delete</title>
            <path class="path1" d="M17.723 28c0.543 0 0.984-0.448 0.984-1v-12c0-0.552-0.441-1-0.984-1s-0.985 0.448-0.985 1v12c0 0.552 0.441 1 0.985 1v0zM7.877 28c0.543 0 0.984-0.448 0.984-1v-12c0-0.552-0.441-1-0.984-1s-0.985 0.448-0.985 1v12c0 0.552 0.441 1 0.985 1v0zM12.8 28c0.543 0 0.985-0.448 0.985-1v-12c0-0.552-0.441-1-0.985-1s-0.984 0.448-0.984 1v12c0 0.552 0.441 1 0.984 1v0zM23.631 4h-5.908v-2c0-1.104-0.882-2-1.969-2h-5.908c-1.087 0-1.969 0.896-1.969 2v2h-5.908c-1.087 0-1.969 0.896-1.969 2v2c0 1.104 0.882 2 1.969 2v18c0 2.208 1.765 4 3.939 4h13.784c2.174 0 3.938-1.792 3.938-4v-18c1.087 0 1.969-0.896 1.969-2v-2c0-1.104-0.882-2-1.969-2v0zM9.846 3c0-0.552 0.441-1 0.984-1h3.938c0.544 0 0.985 0.448 0.985 1v1h-5.908v-1zM21.662 28c0 1.104-0.882 2-1.969 2h-13.784c-1.087 0-1.97-0.896-1.97-2v-18h17.723v18zM22.646 8h-19.692c-0.543 0-0.985-0.448-0.985-1s0.441-1 0.985-1h19.692c0.543 0 0.984 0.448 0.984 1s-0.441 1-0.984 1v0z"></path>
            </symbol>
            <symbol id="icon-clock" viewBox="0 0 32 32">
                <title>clock</title>
                <path class="path1" d="M29.333 16c0-7.364-5.97-13.333-13.333-13.333s-13.333 5.97-13.333 13.333c0 7.364 5.97 13.333 13.333 13.333s13.333-5.97 13.333-13.333v0 0 0 0 0 0zM0 16c0-8.837 7.163-16 16-16s16 7.163 16 16c0 8.837-7.163 16-16 16s-16-7.163-16-16zM14.667 14.667v1.333h2.667v-10.667h-2.667v9.333zM24 18.667h1.333v-2.667h-10.667v2.667h9.333z"></path>
            </symbol>
        </defs>
    </svg>

    <div class="container">
        <div class="checkout-addr">
            <!-- process step -->
            <div class="check-step">
                <ul>
                    <li class="cur">地址确认</li>
                    <li>查看订单</li>
                    <li>支付</li>
                    <li>订单确认</li>
                </ul>
            </div>

            <!-- address list -->
            <div class="checkout-title">
                <span>配送地址</span>
            </div>
            <div class="addr-list-wrap">
                <div class="addr-list">
                    <ul>
                        <li v-for="(item,index) in filterAddress">
                            <dl>
                                <dt>{{item.userName}}</dt>
                                <dd class="address">{{item.streetName}}</dd>
                                <dd class="tel">{{item.tel}}</dd>
                            </dl>
                            <div class="addr-opration addr-edit">
                                <a href="javascript:;" class="addr-edit-btn">
                                    <svg class="icon icon-edit"><use xlink:href="#icon-edit"></use></svg>
                                </a>
                            </div>
                            <div class="addr-opration addr-del">
                                <a href="javascript:;" class="addr-del-btn">
                                    <svg class="icon icon-del"><use xlink:href="#icon-del"></use></svg>
                                </a>
                            </div>
                            <div class="addr-opration addr-set-default">
                                <a href="javascript:;" class="addr-set-default-btn"  v-if="!item.isDefault"><i>设为默认</i></a>
                            </div>
                            <div class="addr-opration addr-default" v-if="item.isDefault">默认地址</div>
                        </li>

                        <li class="addr-new">
                            <div class="add-new-inner">
                                <i class="icon-add">
                                    <svg class="icon icon-add"><use xlink:href="#icon-add"></use></svg>
                                </i>
                                <p>添加新地址</p>
                            </div>
                        </li>
                    </ul>
                </div>

                <div class="shipping-addr-more">
                    <!--<a class="addr-more-btn up-down-btn" href="javascript:;" @click="loadMore();">-->
                    <!--<a class="addr-more-btn up-down-btn" href="javascript:;" @click="loadMore">-->
                    <a class="addr-more-btn up-down-btn" href="javascript:;" @click="limitNum=addressList.length">
                        <!--错误实例@click="this.limitNum=addressList.length"-->
                        more
                        <i class="i-up-down">
                            <i class="i-up-down-l"></i>
                            <i class="i-up-down-r"></i>
                        </i>
                    </a>
                </div>
            </div>

            <!-- shipping method-->
            <div class="checkout-title">
                <span>配送方式</span>
            </div>
            <div class="shipping-method-wrap">
                <div class="shipping-method">
                    <ul>
                        <li class="check">
                            <div class="name">标准配送</div>
                            <div class="price">Free</div>
                        </li>
                        <li>
                            <div class="name">高级配送</div>
                            <div class="price">180</div>
                        </li>
                    </ul>
                </div>
            </div>

            <div class="next-btn-wrap">
                <a href="javascript:;" class="btn btn--red">下一步</a>
            </div>
        </div>
    </div>
    <script src="js/lib/vue.min.js"></script>
    <script src="js/lib/vue-resource.min.js"></script>
<script src="js/address.js"></script>
</body>
</html>

3、address.json

/**
 * Created by kk on 2017/4/20.
 */
new Vue({
    el:".container",
    data:{
        limitNum:3,
    addressList:[]
},
mounted:function () {
    this.$nextTick(function(){
       // alter();

        this.getAddressList();
    });
},
    computed:{
        filterAddress:function () {
            return this.addressList.slice(0,this.limitNum);
        //    方法和属性需要加this,不然会找不到
        }
    },
    methods:{
getAddressList:function(){
    var _this=this;
    this.$http.get("data/address.json").then(function(response){
        var res=response.data;
        if(res.status=="0"){
            _this.addressList=res.result;
        }
    });
}
        ,
    loadMore:function () {
        this.limitNum=this.addressList.length;
    }

}
});

4、address.css

{
  "status":"0",
  "message":"",
  "result":[
    {
      "addressId":"100001",
      "userName":"JackBean",
      "streetName":"北京市朝阳区朝阳公园",
      "postCode":"100001",
      "tel":"12345678901",
      "isDefault":true
    },
    {
      "addressId":"100002",
      "userName":"JackBean",
      "streetName":"北京市朝阳区朝阳公园",
      "postCode":"100001",
      "tel":"12345678901",
      "isDefault":false
    },
    {
      "addressId":"100003",
      "userName":"JackBean",
      "streetName":"北京市朝阳区朝阳公园",
      "postCode":"100001",
      "tel":"12345678901",
      "isDefault":false
    },
    {
      "addressId":"100004",
      "userName":"JackBean",
      "streetName":"北京市朝阳区朝阳公园",
      "postCode":"100001",
      "tel":"12345678901",
      "isDefault":false
    },
    {
      "addressId":"100005",
      "userName":"JackBean",
      "streetName":"北京市朝阳区朝阳公园",
      "postCode":"100001",
      "tel":"12345678901",
      "isDefault":false
    }
  ]
}
时间: 2024-12-11 17:29:58

vue遍历时添加个数过滤条件的相关文章

在后台为查询表格添加固定过滤条件

一.新建一个列表页面,在页面中功能中增加如下配置: 二.写一个handler处理类: 在filterItems中加入固定的过滤条件即可 或者 FilterInfo filter = new FilterInfo();        filter.getFilterItems().add(new FilterItemInfo("person.id", personId.toString()));        filter.getFilterItems().add(new FilterI

.NET深入实战系列--EF到底怎么写过滤条件

本文唯一访问地址:http://www.cnblogs.com/yubaolee/p/DynamicLinq.html 对于系统开发来说,按不同字段进行过滤查询是一种常见的需求.在EF中通常的做法是: /// <summary> /// 只是简单举例,只用了两个过滤条件 /// </summary> IEnumerable<UserInfo> Search(string username = "", string usertype = "&

.NET深入实战系列--EF到底怎么写过滤条件(转)

原文来自:http://www.cnblogs.com/yubaolee/p/DynamicLinq.html 对于系统开发来说,按不同字段进行过滤查询是一种常见的需求.在EF中通常的做法是: /// <summary> /// 只是简单举例,只用了两个过滤条件 /// </summary> IEnumerable<UserInfo> Search(string username = "", string usertype = ""

自定义 Azure Table storage 查询过滤条件

本文是在Azure Table storage 基本用法一文的基础上,介绍如何自定义 Azure Table storage 的查询过滤条件.如果您还不太清楚 Azure Table storage 的基本用法,请先移步前文. 文章来源:葡萄城产品技术社区 让我们回到前文中提到的一个问题,如何过滤出 MyLogTable 表中某一天产生的所有日志?在进入细节之前,我们先来回顾一下 MyLogTable 类的设计: internalclassMyLogEntity : TableEntity {

Magento模型集合addFieldToFilter常用过滤条件

记录一下Magento模型集合Model Collection中addFieldToFilter()方法常用的过滤条件.以下参数也同样适用于产品实体的addAttributeToFilter()方法. //等于 Equals: eq $_products->addAttributeToFilter('status', array('eq' => 1)); //不等于 Not Equals - neq $_products->addAttributeToFilter('sku', arra

一站式学习Wireshark(八):应用Wireshark过滤条件抓取特定数据流

应用抓包过滤,选择Capture | Options,扩展窗口查看到Capture Filter栏.双击选定的接口,如下图所示,弹出Edit Interface Settints窗口. 下图显示了Edit Interface Settings窗口,这里可以设置抓包过滤条件.如果你确知抓包过滤条件的语法,直接在Capture Filter区域输入.在输入错误时,Wireshark通过红色背景区域表明无法处理过滤条件.最有可能的情况是,过滤条件中含有输入错误,或是使用了display filter的

解决 执行计划看不到过滤条件 出现&#39;PLAN_TABLE&#39; is old version的问题

解决 'PLAN_TABLE' is old version 分析sql执行计划时,遇到'PLAN_TABLE' is old version细想起来,数据库是从低版本升级的,估计是这个原因 解决方法: 删除plan_table重建 SQL>explain plan for select * from users; Explained. SQL>select * from table(dbms_xplan.display); PLAN_TABLE_OUTPUT-----------------

WirShark系列: 使用WireShark过滤条件抓取特定数据流(zz)

应用抓包过滤,选择Capture | Options,扩展窗口查看到Capture Filter栏.双击选定的接口,如下图所示,弹出Edit Interface Settints窗口. 下图显示了Edit Interface Settings窗口,这里可以设置抓包过滤条件.如果你确知抓包过滤条件的语法,直接在Capture Filter区域输入.在输入错误时,Wireshark通过红色背景区域表明无法处理过滤条件.最有可能的情况是,过滤条件中含有输入错误,或是使用了display filter的

Informatica 常用组件Filter之 过滤条件

过滤条件可以使用转换语言输入.过滤条件是返回 TRUE 或 FALSE 的表达式.例如,如果您要过滤出员工薪水低于 $30,000 的行,可输入以下条件: SALARY > 30000 可以使用 AND 和 OR 逻辑运算符来指定多个条件组合.如果要过滤掉薪水低于 $30,000 和多于 $100,000 的员工,您可输入以下条件: SALARY > 30000 AND SALARY < 100000 无需指定 TRUE 或 FALSE 作为表达式中的值.TRUE 和 FALSE 为您设