//自定义提示vant sku组件未选择中属性中的必选属性提示
[JavaScript] 纯文本查看 复制代码 customSkuValidator: (value) => {
//未选属性
let selectedText = value.selectedText;
selectedText = selectedText.split(' ');
selectedText.shift();
//必选属性
let requiredAttributes = [];
for (let i = 0; i < value.propList.length; i++) {
if(value.propList[i].is_necessary){
requiredAttributes.push(value.propList[i].k);
}
}
//对比
let reminder = '请选择:';
selectedText.forEach(function(val) {
if(requiredAttributes.indexOf(val) > -1){
reminder += val+',';
}
});
reminder = reminder.substr(0, reminder.length - 1);
//return value.selectedText;
return reminder;
},
|