vue向list中添加数据_vue中给请求来的数据List ,添加属性false 后,赋值不上问题解决办法...

data() {

return {

list:[

// 添加属性fale 后的值

],

// 测试数据

goList:[

{

name:'张三',

phone:'18621958665'

},

{

name:'李四',

phone:'18621958665'

},

{

name:'张er',

phone:'18621958665'

},

{

name:'李wu',

phone:'18621958665'

}

],

routerList:[]

}

},

// 数据请求

getAjax(){

const _this = this

// _this.postRequest('‘, {}, function (data) {

// console.log(data, '111')

// if (data) {

// data.map(val => {

// val.check = false ;

// _this.list.push(val)

// })

// }else{

// _this.$Toast({

// message: '请选择使用人',

// duration: 2000,

// className: 'noticeErrorToast'

// });

// }

// })

_this.goList.map(val => {

val.check = false ; // 添加属性

_this.list.push(val)

})

},

// 点击切换选中

goChecked(item,index){

const _this = this ;

// 第二种

// this.$set(item,'check',!item.check) //undefined 直接转化true

//第一种

item.check = !item.check ;

this.list.splice(index,1,item); // 有将当前的直接改变掉,替换掉

if(item.check){

this.routerList.push(item)

}else{

this.routerList.splice(index,1)

}

console.log(this.routerList) // 获取到当前选中的值

},

多选按钮点击事件html:

{{item.name}}{{item.phone}}

css:

.registrationList{

width: 100%;

box-sizing: border-box;

padding: 20px 0 20px 20px ;

}

.registrationList ul{

width: 100%;

box-sizing: border-box;

padding:20px 0 ;

border-bottom: 1px solid #f5f5f5;

display: flex;

}

.registrationList ul div:first-of-type{

display: flex;

justify-content: center;

align-items: center;

margin-right: 20px;

}

.registrationList li{

width: 100%;

box-sizing: border-box;

line-height: 50px;

text-align: left;

}

.registrationList img{

vertical-align: middle;

width: 36px;

height: 36px;

}

.firstLi{

font-size: 34px;

color:black;

}

.secondLi{

font-size: 28px;

font-family:PingFang SC;

font-weight:400;

color:rgba(153,153,153,1);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值