简体   繁体   中英

How to make multiselect work in sails.js using built in vue and ajax forms?

Im trying to using a simple multiselect form with standard sails.js 1.0 using ajax / vue. Everything seems right according to Vue.js site, but I'm getting errors:

On screen errors: Error: In directive model inserted hook: expects an Array value for its binding, but got Undefined.

This is a simplified version, throws same errors as a select with all the ajax properties filled in.

<select v-model="formData.select" multiple>
<option>A</option>
<option>B</option>
<option>C</option>
</select>

The above will work without the v-model="" included OR without the 'multiple' included, but how could I make this work as-is in Sails.js?

In sails, seems the 'formData' field autogenerates using an array for form fields, so I just hardcoded in the v-model="formData.select" to below and seems to eliminate the error.

xxx.page.js file:

data: {
formData: { /* … */
            'select': [],
        },

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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