CustomComponent.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <div class="custom-component" :style="{
  3. width,
  4. height
  5. }">
  6. <span>
  7. 宽:<el-input v-model="dataModel.width" :disabled="disabled" style="width: 200px;"></el-input>
  8. </span>
  9. <span>
  10. 高:<el-input v-model="dataModel.height" :disabled="disabled" style="width: 200px;"></el-input>
  11. </span>
  12. <div>{{tip}}</div>
  13. </div>
  14. </template>
  15. <script>
  16. export default {
  17. name: 'custom-width-height',
  18. props: {
  19. value: {
  20. type: Object,
  21. default: () => ({})
  22. },
  23. width: {
  24. type: String,
  25. default: ''
  26. },
  27. height: {
  28. type: String,
  29. default: ''
  30. },
  31. disabled: {
  32. type: Boolean,
  33. default: false
  34. },
  35. tip: {
  36. type: String,
  37. default: ''
  38. }
  39. },
  40. data() {
  41. return {
  42. dataModel: this.value
  43. }
  44. },
  45. mounted () {
  46. this.$emit('on-test', 'abc', '111')
  47. },
  48. watch: {
  49. value (val) {
  50. this.dataModel = val
  51. },
  52. dataModel (val) {
  53. this.$emit('input', val)
  54. }
  55. }
  56. }
  57. </script>
  58. <style lang="scss">
  59. .custom-component{
  60. background: #eee;
  61. padding: 10px;
  62. span{
  63. +span{
  64. margin-left: 10px;
  65. }
  66. }
  67. }
  68. </style>