matiastucci / vue-input-tag

:bookmark: Vue.js 2.0 Input Tag Component
https://tucci.me/vue-input-tag
MIT License
536 stars 135 forks source link

add async function support for `before-adding` and `validate` props #104

Closed ywmail closed 5 years ago

ywmail commented 5 years ago

I need the value to be validated by the server side before added to innerTags when user hit Enter, so the validate and before-adding function should return a promise, for example:

    validate(val) {
      return new Promise((resolve, reject) => {

        this.dataAuthorityService.getAuthorityFromAccount(val).then(res => {
          if (res.data.length > 0) {
            resolve(res.data.id)
          }
          else {
            alert('failed')
          }
        }).catch(error => {
           alert('failed')
        })

      })