vue设置默认地址和配送方式
1、截图
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"> <div class="container"> <div class="addr-list-wrap">
<div class="addr-list">
<ul>
<li v-for="(item,index) in filterAddress" v-bind:class="{'check':index==currentIndex}" @click="currentIndex=index"> <div class="addr-opration addr-set-default">
<a href="javascript:;" class="addr-set-default-btn" v-if="!item.isDefault" @click="setDefault(item.addressId);"><i>设为默认</i></a>
</div>
<div class="addr-opration addr-default" v-if="item.isDefault">默认地址</div>
</li> <!-- shipping method-->
<div class="checkout-title">
<span>配送方式</span>
</div>
<div class="shipping-method-wrap">
<div class="shipping-method">
<ul>
<li :class="{'check':shippingMethod==1}" @click="shippingMethod=1">
<!--注意绑定是{}和‘’-->
<div class="name" >标准配送</div>
<div class="price">Free</div>
</li>
<li :class="{'check':shippingMethod==2}" @click="shippingMethod=2">
<div class="name" >高级配送</div>
<div class="price">180</div>
</li>
</ul>
</div>
</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.js
/**
* Created by kk on 2017/4/20.
*/
new Vue({
el:".container",
data:{
limitNum:3,
addressList:[],
currentIndex:0,
shippingMethod:1
},
mounted:function () {
this.$nextTick(function(){
// alter(); this.getAddressList();
});
},
computed:{
filterAddress:function () {
return this.addressList.slice(0,this.limitNum);
// 方法和属性需要加this,不然会找不到
}
},
methods:{ setDefault:function (addressId) {
this.addressList.forEach(function (address,index) {
if(address.addressId==addressId)
{
address.isDefault=true;
}
else{
address.isDefault=false;
}
}) } }
});
vue设置默认地址和配送方式的更多相关文章
- discuz首页设置默认地址不带forum.php后缀的方法
最近在研究discuz,上传安装几部搞定,打开首页跳到含有"/forum.php"的网址,到管理中心改了好一会儿也没好.那么如何实现discuz首页设置不带forum.php后缀呢 ...
- myeclipse设置默认的jsp打开方式
- ecshop 订单-》设置默认收货地址,或者删除
设置位置:ecs_users标的 country字段,默认是0,默认地址是 users_address 的address_id 设置默认收货地址 /** * 设置默认地址 * * @access ...
- Vue nodejs商城-地址模块
一.地址列表渲染 ,则不可以点击. src/views/Cart.vue <a class="btn btn--red" v-bind:class="{'btn-- ...
- vue2购物车ch4-(筛选v-for 点击的那个设置样式 设为默认地址其他 联动 非循环的列表选中和非选中 删除当前选中的列表)
1 address.html <!DOCTYPE html> <html lang="en"> <head> <meta charset= ...
- Vue cli4 图片地址引入的几种方式
五种图片地址引入方式 @开头,它也会作为一个模块请求被解析.它的用处在于Vue CLI默认会设置一个指向项目根目录/src的别名@
- 【转】Centos 设置IP地址的几种方式
对于很多刚刚接触linux的朋友来说,如何设置linux系统的IP地址,作为第一步,下面小编以centos系统为例,给大家演示如何给centos设置IP地址,如何修改linux 系统IP地址? 查看I ...
- Eclipse Class Decompiler影响class默认打开方式,重新设置Eclipse默认源码打开方式
安装Eclipse Class Decompiler插件后,Eclipse中的默认源码打开方式被修改为Eclipse Class Decompiler 这不是我喜欢的,因为我希望,源码从网络中获取,当 ...
- 【转载】win10解决设置默认打开方式不生效问题(双击每次都要选择默认打开程序)
win10解决设置默认打开方式不生效问题(双击每次都要选择默认打开程序) 以下文章 部分选自 https://blog.csdn.net/shan165310175/article/details/8 ...
随机推荐
- 基于python的机器学习开发环境安装(最简单的初步开发环境)
一.安装Python 1.下载安装python3.6 https://www.python.org/getit/ 2.配置环境变量(2个) 略...... 二.安装Python算法库 安装顺序:Num ...
- 求链表的倒数第m个元素
法一: 首先遍历一遍单链表,求出整个单链表的长度n,然后将倒数第m个,转换为正数第n-m+1个,接下去遍历一次就可以得到结果. 不过这种方法需要对链表进行两次遍历,第一次遍历用于求解单链表的长度,第二 ...
- 洛谷 P1433 吃奶酪【DFS】+剪枝
题目链接:https://www.luogu.org/problemnew/show/P1433 题目描述 房间里放着n块奶酪.一只小老鼠要把它们都吃掉,问至少要跑多少距离?老鼠一开始在(0,0)点处 ...
- C、C++ 学习经历
1.可以考虑先学习C. 大多数时候,我们学习语言的目的,不是为了成为一个语言专家,而是希望成为一个解决问题的专家.做一个有用的程序员,做一个赚钱的程序员.我们的价值,将体现在客户价值上,而不是语言写得 ...
- Android的onLayout、layout方法讲解
onLayout方法是ViewGroup中子View的布局方法,用于放置子View的位置.放置子View很简单,只需在重写onLayout方法,然后获取子View的实例,调用子View的layout方 ...
- Instruments
链接: iOS性能优化:Instruments使用实战 iOS 使用Instruments的工具小结
- vsftp安装与配置for Linux
以Centos6中使用为例 1.安装 yum -y install vsftpd 2.基本配置 vi /etc/vsftpd/vsftpd.conf 匿名访问和切换根目录都会给服务器带来安全风险,我们 ...
- Android笔记(四):RecyclerView
RecyclerView是ListView的增强版.有了它之后,你就可以抛弃ListView了. recycle,重复利用.在ListView里,我们得自己写重复利用View的代码,而Recycler ...
- [原创]PostMan接口测试神器
[原创]PostMan接口测试神器 1 PostMan是什么? Postman是一款功能强大的网页调试与发送网页HTTP请求的Chrome插件. 2 Postman工具下载及安装 官方网站: htt ...
- Makefile 中的.PHONY
PHONY 目标并非实际的文件名:只是在显式请求时执行命令的名字.有两种理由需要使用PHONY 目标:避免和同名文件冲突,改善性能. 所谓的PHONY这个单词就是伪造的意思,makefile中将.PH ...