2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
P85: After publishing a product and clicking Next, it is found that the specification parameters are not displayed
Open the console and find that the error forEach... error
After checking the cause of the problem, I found that the associated attributes of individual groups in the returned grouping (attrs) may be null
So at this time, you need to ensure that the attrs returned by the backend cannot be null
Method 1: Backend filtering: In the backend implementation class, determine and remove groups with attrs being null.
- **
- * 根据分类id查出所有分组和分组属性
- * @param catelogId
- * @return
- */
- @Override
- public List<AttrGroupWithAttrsVo> getAttrGroupWithAttrsByCatelogId(Long catelogId) {
- //获得在属性分组表中的所有属于当前分类的实体
- List<AttrGroupEntity> attrGroupEntities = this.list(new QueryWrapper<AttrGroupEntity>().eq("catelog_id", catelogId));
- List<AttrGroupWithAttrsVo> collect = attrGroupEntities.stream().map((group) -> {
- AttrGroupWithAttrsVo attrsVo = new AttrGroupWithAttrsVo();
- BeanUtils.copyProperties(group,attrsVo);
- //当前分组下的所有属性(没有"valueType": 0,)
- List<AttrEntity> attr = attrService.getRelationAttr(attrsVo.getAttrGroupId());
- attrsVo.setAttrs(attr);
- if ( attr!=null){
- return attrsVo;
- }
- return null;
- }).collect(Collectors.toList());
- collect.removeIf(Objects::isNull);
- return collect;
- }
Method 2: Add if judgment to the front-end page.showBaseAttrs()
Methodfor each
Add one in frontIf judgment
if (item.attrs != null && item.attrs.length > 0)