使用vue实现多规格选择实例(SKU)

2020-06-12 21:15:59易采站长站整理

}
if(this.shopItemInfo[result]){
this.price = this.shopItemInfo[result].price || ''
}
self.$forceUpdate(); //重绘
},
isMay: function (result) {
for (var i in result) {
if (result[i] == '') {
return true; //如果数组里有为空的值,那直接返回true
}
}
return this.shopItemInfo[result].stock == 0 ? false : true; //匹配选中的数据的库存,若不为空返回true反之返回false
}
},
created: function () {
var self = this;
for (var i in self.simulatedDATA.difference) {
self.shopItemInfo[self.simulatedDATA.difference[i].difference] = self.simulatedDATA.difference[i]; //修改数据结构格式,改成键值对的方式,以方便和选中之后的值进行匹配
}
self.checkItem();
}
}
</script>

3.css


<style lang="scss" rel="stylesheet">
.wrap-sku {
.product-box {
width: 1200px;
display: block;
margin: 0 auto;
}
.product-content {
margin-bottom: 100px;
}
.product-delcom {
color: #323232;
font-size: 26px;
border-bottom: 1px solid #EEEEEE;
padding: 30px 0;
}
.product-footerlist {
margin-top: 10px;
}
.product-footerlist li {
border: 1px solid #606060;
border-radius: 5px;
color: #606060;
text-align: center;
padding: 10px 30px;
float: left;
margin-right: 20px;
cursor: pointer;
}
.product-footerlist li.productActive {
background-color: #1A1A29;
color: #fff;
border: 1px solid #1A1A29;
}
.product-footerlist li.noneActive {
background-color: #ccc;
opacity: 0.4;
color: #000;
pointer-events: none;
}
.product-footer {
background-color: #1A1A29;
text-align: center;
}
.product-footer a {
color: #fff;
text-decoration: none;
height: 88px;
line-height: 88px;
font-size: 28px;
}
.price{
font-size: 30px;
height: 60px;
line-height: 60px;
}
}
</style>

4.最后当然是上效果图了