iview table展示图片、文字,判断显示相应内容

在项目中使用iview的table控件时,遇到的问题:

1.表格如何显示图片(居中):

{
	title: '户籍照片',
	type: 'photoUrl',
	align: 'center',
	render: (h, params) => {
		return h("div",{
				style: { height: "100px", margin: "10px",overflow:'hidden',position:'relative' }
			} ,
			[h("img", {
					attrs: { src: params.row.photoUrl },
					style: {maxWidth:'100%',maxHeight:'100%',verticalAlign:'middle',position:'absolute',top:'50%',left:'50%',transform:'translate(-50%,-50%)' }
				}
			)]
		);
	}
}

2.如何根据值显示相应文本内容:

{
	title: '性别',
	key: 'gender',
	align: 'center',
	render:(h, params) => {
		let gender = params.row.gender
		if(gender == 1){
			gender = '男'
		}else if(gender == 2){
			gender = '女'
		}
		return h('span',gender)
	}
}

3.对应显示内容:

{
	title: '操作',
	key: 'operate3',
	align: 'center',
	render: (h, params) => {
		return h('div', [
			params.row.pkUserID == 'SUPERADMIN'?h('Button', {
				props: {
					type: 'primary',
					// size: 'small'
				},
				style: {
					margin:'20px 15px 20px 0px'
				},
				on: {
					click: () => {
						this.initEditPsw(params.row)
					}
				}
			}, '修改密码'):
			h('Button', {
				props: {
					type: 'primary',
					// size: 'small'
				},
				style: {
					margin:'20px 15px 20px 0px'
				},
				on: {
					click: () => {
						this.userEdit(params.row)
					}
				}
			}, '修改'),
			params.row.pkUserID == 'SUPERADMIN'?'':h('Button', {
				props: {
					type: 'primary',
					// size: 'small'
				},
				on: {
					click: () => {
						this.delete('user',params.row)
					}
				}
			}, '删除')
		]);
	}
}

或者

{
    title:"操作",
     key:"actor",
     align:'center',
     render: (h, params) => {
       if(this.giftCardsList[params.index].status === '进行中'){
         return h('div', [
             h('Button', {
                 props: {
                     type: 'primary',
                     size: 'small'
                 },
                 style: {
                     marginRight: '5px'
                 },
                 on: {
                     click: () => {
                         this.$router.push({ path: '../marketing_manage/add_gift_card?gcid=' + this.giftCardsList[params.index].gcid});
                     }
                 }
             }, '编辑'),
             h('Button', {
                 props: {
                     type: 'error',
                     size: 'small'
                 },
                 on: {
                     click: () => {
                         this.popupIsShow = true; 
                         this.gcid = this.giftCardsList[params.index].gcid;
                     }
                 }
             }, '使失效')
         ]);
       }else{
         return h('div', [
             h('Button', {
                 props: {
                     type: 'primary',
                     size: 'small'
                 },
                 on: {
                     click: () => {
                         this.$router.push({ path: '../marketing_manage/gift_card_warehouse?gcid=' + this.giftCardsList[params.index].gcid});
                     }
                 }
             }, '码库')
         ]);
       }
     }
   }
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值