简体   繁体   English

如何在语义UI vue下拉列表中使用动态键传递数据?

[英]How to pass the data with dynamic key in semantic UI vue dropdown?

I am facing an issue with semantic-ui-vue dropdown. 我面临semantic-ui-vue下拉菜单的问题。

Here is my sandbox link: https://codesandbox.io/s/3qknm52pm5 . 这是我的沙盒链接: https : //codesandbox.io/s/3qknm52pm5

In my sandbox, I have two dropdowns: From and To . 在我的沙箱中,我有两个下拉菜单: FromTo

From shows the correct values and To doesn't due to key mismatch. From显示正确的值,而To则不是由于密钥不匹配而导致的。

My App.vue contain this script 我的App.vue包含此脚本

<script>
export default {
  data() {
    return {
      from: [],
      to: [],
      fromCollection: [
        {
          value: "abc@gmail.com",
          text: "abc@gmail.com"
        },
        {
          value: "def@gmail.com",
          text: "def@gmail.com"
        },
        {
          value: "qwerty@gmail.com",
          text: "qwerty@gmail.com"
        },
        {
          value: "shubham@gmail.com",
          text: "shubham@gmail.com"
        }
      ],
      toCollection: [
        {
          email: "abc@gmail.com"
        },
        {
          email: "def@gmail.com"
        },
        {
          email: "qwerty@gmail.com"
        },
        {
          email: "shubham@gmail.com"
        }
      ]
    };
  }
};
</script>

and the component I used for both of them are 而我用于两者的组件是

<sui-dropdown
      fluid
      multiple
      :options="fromCollection"
      placeholder="from"
      selection
      v-model="from"
      search
      :allowAdditions="true"
      text="email"
    />
<sui-dropdown
      fluid
      multiple
      :options="toCollection"
      placeholder="from"
      selection
      v-model="to"
      search
      :allowAdditions="true"
      text="email"
    />

The 1st dropdown shows the correct values because I have passed the data from fromCollection whereas the 2nd dropdown doesn't show any text because I have passed the data from toCollection which has different key names. 第一个下拉列表显示正确的值,因为我已经从fromCollection传递了数据,而第二个下拉列表却没有显示任何文本,因为我从toCollection传递了具有不同键名的数据。

Can someone help me to pass the data with dynamic keys like toCollection ? 有人可以帮助我使用诸如toCollection类的动态键传递数据吗?

I couldn't find anything related in the documentation . 我在文档中找不到任何相关内容 Can someone help? 有人可以帮忙吗?

there is no way to define field name for dropdown 无法定义下拉列表的字段名称

only use computed to regenerate new array for it 仅使用计算为它重新生成新数组

demo 演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM