NewSelect.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <el-select
  3. size="small"
  4. class="re-select-container"
  5. v-model="imgValue"
  6. placeholder="请选择"
  7. @change="currentSel"
  8. >
  9. <!-- popper-append-to-body:是否将弹出菜单插入至 body 元素。在菜单的定位出现问题时,可尝试修改该属性-->
  10. <el-option
  11. v-for="item in options"
  12. :key="item.value"
  13. :label="item.label"
  14. :value="item.value"
  15. >
  16. </el-option>
  17. </el-select>
  18. </template>
  19. <script>
  20. export default {
  21. name: "NewSelect",
  22. props: {
  23. options: {
  24. type: Array,
  25. default() {
  26. return [];
  27. },
  28. },
  29. value: [String, Number],
  30. popper: {
  31. type: Boolean,
  32. default: false,
  33. },
  34. },
  35. model: {
  36. prop: "value", //绑定的值,通过父组件传递,
  37. event: "selectEvent", //自定义事件名
  38. },
  39. data() {
  40. return {
  41. imgValue: this.value,
  42. };
  43. },
  44. watch: {
  45. imgValue(nv) {
  46. this.$emit("changeColor", nv);
  47. },
  48. },
  49. created() {
  50. // console.log(this.imgValue);
  51. },
  52. mounted() {},
  53. methods: {
  54. currentSel() {
  55. this.$emit("selectEvent", this.imgValue);
  56. },
  57. },
  58. };
  59. </script>
  60. <style lang="less" scoped>
  61. .re-select-container {
  62. font-size: 1rem;
  63. .select-trigger {
  64. height: 100%;
  65. }
  66. .el-input--suffix {
  67. height: 100%;
  68. .el-input__inner {
  69. height: 100%;
  70. line-height: 100%;
  71. }
  72. }
  73. .el-input--suffix .el-input__inner {
  74. background: transparent !important;
  75. }
  76. }
  77. </style>