下面的代码h5可以实现,编译到手机端就不行了
有没有兼容的写法啊
<template>
<view class="container">
<view class="list-box">
<view class="cell" v-for="(item,index) in rList" :key="index" :class="{'cur': rSelect.indexOf(item)!=-1}" @click="rChoose(item)">
{{item}}
</view>
</view>
</view>
</template>
<script>
export default {
data(){
return{
rList:['全部','商品新增入库','普通入库','调拨入库','调拨驳回入库','盘点入库','其他入库'],
rSelect:['全部'],
},
methods:{
rChoose(value){
if(this.rSelect.indexOf( value )!=-1){
this.rSelect.splice( this.rSelect.indexOf( value), 1 );
}else{
this.rSelect.push(value);
}
},
}
},
</script>
<style lang="scss" scoped>
.container{
height: 100%;
}
.list-box{
padding: 6upx 20upx;
display: flex;
flex-flow: row wrap;
align-items: center;
.cell{
width:150upx;
height: 72upx;
line-height: 72upx;
margin: 16upx 32upx 16upx 0;
border: 1upx dotted #f5f5f5;
border-radius: 8upx;
text-align: center;
font-size: 28upx;
overflow: hidden;
&:nth-child(4n){
margin: 16upx 0;
}
&.cur{
background-color: #ff6a3f;
border: 1upx dotted #ff6a3f;
color: #fff;
}
}
}
</style >
w***@qq.com (作者)
试过计算属性也试过写成方法都不行,有没有解决方法呀,
2019-05-31 09:13