ElemeFE / element

A Vue.js 2.0 UI Toolkit for Web
https://element.eleme.io/
MIT License
54.12k stars 14.64k forks source link

[Bug Report] this.$parent.computePresentText is not a function in el-cascader-panel component #19808

Open bulatie opened 4 years ago

bulatie commented 4 years ago

Element UI version

2.13.2

OS/Browsers version

MacOS Mojave 10.14.6 / Chrome Version 83.0.4103.116 (Official Build) (64-bit)

Vue version

2.6.11

Reproduction Link

https://codepen.io/bulatie/pen/yLejzOZ

Steps to reproduce

As codepen demo.

Similar issue: https://github.com/ElemeFE/element/issues/18664

What is Expected?

Each value of level should be checked in its menu

What is actually happening?

Just first value of level be selected, and third level menu is not able to show up.

LuckyStarry commented 3 years ago

在对有默认值的级联菜单做初始化的场景遇到了同样的问题,用其他方法解决的 具体是:在初始化的时候,将默认选项相关的列表赋值到options

举个栗子: 比如默认值的ID数组是 [1000, 1200, 1201],那么就生成一个类似如下的数组赋值给options

[{
    "label": "LABEL_1000",
    "value": 1000,
    "children": [{
        "label": "LABEL_1100",
        "value": 1100,
        "children": []
    }, {
        "label": "LABEL_1200",
        "value": 1200,
        "children": [{
            "label": "LABEL_1201",
            "value": 1201,
            "children": []
        }, {
            "label": "LABEL_1202",
            "value": 1201,
            "children": []
        }, {
            "label": "LABEL_1203",
            "value": 1201,
            "children": []
        }]
    }, {
        "label": "LABEL_1300",
        "value": 1300,
        "children": []
    }]
}, {
    "label": "LABEL_2000",
    "value": 2000,
    "children": []
}, {
    "label": "LABEL_3000",
    "value": 3000,
    "children": []
}]

虽然这个方法可能减少了N次级联查询,但是感觉对性能要求不敏感的一些站点,额外增加了工作量,不是很优雅。

翻看了下源码,觉得这个可能是BUG的代码很奇怪,全局检索下来 computePresentText 好像是 cascader 组件的一个方法,但 cascader-panel 却根本就没引用 cascader 组件,不知道为啥会写这么一个语句。

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.