2017-10-17 104 views
0

我有一些響應數據從服務器回來,這是一個很好的安裝的axios調用。Vue.js Multiselect中的數據

進出口尋找使用的某一部分,如多選一選擇選項:選擇

Vue公司看起來像這樣

// ===Component name 
    name: "create_order", 
    // ===Props passed to component 
    props: {}, 
    // ===Components used by this component 
    components: { 
     Datepicker, 
     Multiselect, 
    }, 
    // ====component Data properties 
    data(){ 
     return{ 
      formcreateorder: {}, 

      dateoforder: "", 
      format: 'dd MMMM yyyy', 

      orderconsultant: null, 
      orderconsultantoptions: ['Mr', 'Mrs', 'Miss', 'Ms'], 

      ordertype: null, 
      ordertypeoptions: ['Temp', 'Perm'], 

      orderclient: null, 
      orderclientoptions: [] 

     } 
    }, 
    // ===Code to be executed when Component is mounted 
    mounted() { 
     // Make a ajax request to get data from jobs route 
     axios.get('clients/get').then(response => this.orderclientoptions = response.data); 


    }, 
    // ===Computed properties for the component 
    computed: {}, 
    // ===Component methods 
    methods: { 
    } 

我的前端看起來

 <multiselect v-model="orderclient" id="orderclient" name="orderclient" :options="orderclientoptions"></multiselect> 

我的回答是這樣

{id: 1, clientname: "Tech Dojo", industry: "Tech", consultant: "Bob", clientstatus: "Lapsed",…} 

所有我想做的就是使用CLIENTNAME的響應,我多選擇

我已經嘗試了一些方法,但不能得到它的權利而言,我希望你可以幫

+0

嘗試增加的陣列'標籤=「客戶端名」'你的前端,如果通過對象的數組,它需要知道使用哪個領域,我相信標籤的方式指定。 – BenShelton

+0

因此,我添加了標籤,仍然只是得到 – GrahamMorbyDojo

回答

0

如果你只關心客戶端名稱,然後使用客戶端名稱映射對字符串數組的響應結果。我假設你收到客戶

mounted() { 
    axios.get('clients/get') 
     .then(response => 
       this.orderclientoptions = response.data.map(x => x.clientName); 
} 
+0

中的數組數據非常感謝!奇蹟般有效 – GrahamMorbyDojo