Created
October 1, 2018 10:23
-
-
Save wsw70/956d00015c6005767c2a2028c47732fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<el-container> | |
<el-container style="margin-left: 15px; width: 150px"> | |
<el-autocomplete | |
class="inline-input" | |
v-model="user" | |
:fetch-suggestions="filterUsers" | |
placeholder="add user" | |
@select="handleSelect" | |
></el-autocomplete> | |
<el-button type="info" icon="el-icon-plus" @click="addUser(user)">Add</el-button> | |
</el-container> | |
</el-container> | |
</template> | |
<script> | |
import _ from 'lodash' | |
export default { | |
name: "Users", | |
props: { | |
allusers: Array, | |
value: Array | |
}, | |
data() { | |
return { | |
selectedUsers: [], | |
user: '' | |
} | |
}, | |
watch: { | |
selectedUsers() { | |
this.$emit('input', this.selectedUsers) | |
} | |
}, | |
methods: { | |
addUser(user) { | |
this.selectedUsers.push(user) | |
this.user = '' | |
}, | |
filterUsers(user, cb) { | |
console.log(user) | |
cb(['qqq', 'zzz']) | |
//return this.allusers.filter(x => _.includes(x.f+x.t, user)) | |
}, | |
handleSelect() { | |
} | |
}, | |
mounted() { | |
this.selectedUsers = this.value | |
} | |
} | |
</script> | |
<style scoped> | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment