仓库名称仓库类型仓库备注{{item.WarehouseName}}{{item.WarehouseType}}{{item.WarehouseDesc}}js代码:data(){return{warehouses:[{"WarehouseId":1,"WarehouseType":1,"WarehouseName":"深圳仓库","WarehouseDesc":"深圳仓库",},{"WarehouseId":2,"WarehouseType":2,"WarehouseName":"东莞仓库","WarehouseDesc":"东莞仓库",}]}},}其中WarehouseType是枚举算法得到的数值,1代表“默认仓库”,2代表“自建仓库”,现在页面上要怎么样操作能把1和2代表的文字信息展示出来,比如:WarehouseType是1的时候,table中绑定的WarehouseType就展示“默认仓库”4个字?
2 回答
largeQ
TA贡献2039条经验 获得超7个赞
在data中创建一个枚举的json对象WarehourseTypeName:{'1':'默认仓库','2':'自建仓库'}调用{{WarehourseTypeName[item.WarehouseType]}}
繁星淼淼
TA贡献1775条经验 获得超11个赞
也可以使用filters,代码如下:html:{{item.WarehouseName|toText}} {{item.WarehouseType|toText}} {{item.WarehouseDesc|toText}} js:data(){return{warehouses:[{"WarehouseId":1,"WarehouseType":1,"WarehouseName":"深圳仓库","WarehouseDesc":"深圳仓库"},{"WarehouseId":2,"WarehouseType":2,"WarehouseName":"东莞仓库","WarehouseDesc":"东莞仓库"}]}},filters:{toText(val){switch(val){case1:return"默认仓库";case2:return"自建仓库";default:return"";}}}
添加回答
举报
0/150
提交
取消