select.vue 714 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <template>
  2. <el-select v-model="newValue" v-bind="props" v-on="on" multiple>
  3. <el-option
  4. v-for="(item, index) in list"
  5. :value="item.id"
  6. :label="item.name"
  7. :key="index"
  8. ></el-option>
  9. </el-select>
  10. </template>
  11. <script>
  12. export default {
  13. props: {
  14. value: [String, Number, Array],
  15. props: Object,
  16. on: Object
  17. },
  18. data() {
  19. return {
  20. list: [],
  21. newValue: this.value
  22. };
  23. },
  24. watch: {
  25. value(val) {
  26. if (!(val instanceof Array)) {
  27. this.newValue = [val];
  28. } else {
  29. this.newValue = val;
  30. }
  31. },
  32. newValue(val) {
  33. this.$emit('input', val);
  34. }
  35. },
  36. async created() {
  37. this.list = await this.$service.system.role.list();
  38. }
  39. };
  40. </script>
  41. <style lang="stylus" scoped></style>