Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.4k views
in Technique[技术] by (71.8m points)

element cascader 不同层级 value值相同 选中后 input内容显示错误

<el-cascader
          v-model="value2"
          :options="options2"
        ></el-cascader>
value2: [],
      options2: [{
        value: 'zhinan',
        label: '指南',
        children: [
          {
            value: 'shejiyuanze',
            label: '设计原则',
            children: [{
              value: '1',
              label: '1'
            }, {
              value: '2',
              label: '2'
            }, {
              value: 'xiaolv',
              label: '效率'
            }, {
              value: 'kekong',
              label: '可控'
            }
            ]
          }, {
            value: 'daohang',
            label: '导航',
            children: [{
              value: '1',
              label: '1'
            }, {
              value: '2',
              label: '2'
            }
            ]
          }
        ]
      }],

现在的问题是 我的不同2级数据 下的3级数据中都有一个 value: 1

我选择时cascader的文字展示出现错误

image.png

如图 我选择的是导航下面的1 但显示的是2级是设计原则 (右边v-model绑定的值是正确的)

大佬们这个有啥办法解决呀


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

解决方法是 遍历每层数据为 value值加唯一标识 如:value -> xxxxxxx_value 提交给后台时再将选中的value唯一标识去除


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...