CustomComponent.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <div class="custom-component" v-if="!printRead" :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. <div v-else>{{JSON.stringify(dataModel)}}</div>
  15. </template>
  16. <script>
  17. export default {
  18. name: 'custom-width-height',
  19. props: {
  20. modelValue: {
  21. type: Object,
  22. default: () => ({})
  23. },
  24. width: {
  25. type: String,
  26. default: ''
  27. },
  28. height: {
  29. type: String,
  30. default: ''
  31. },
  32. disabled: {
  33. type: Boolean,
  34. default: false
  35. },
  36. tip: {
  37. type: String,
  38. default: ''
  39. },
  40. printRead: {
  41. type: Boolean,
  42. default: false
  43. }
  44. },
  45. data() {
  46. return {
  47. dataModel: this.modelValue
  48. }
  49. },
  50. emits: ['on-test', 'update:modelValue'],
  51. mounted () {
  52. this.$emit('on-test', 'abc', '111')
  53. },
  54. watch: {
  55. modelValue (val) {
  56. this.dataModel = val
  57. },
  58. dataModel (val) {
  59. this.$emit('update:modelValue', val)
  60. }
  61. }
  62. }
  63. </script>
  64. <style lang="scss">
  65. .custom-component{
  66. // background: #eee;
  67. padding: 10px;
  68. span{
  69. +span{
  70. margin-left: 10px;
  71. }
  72. }
  73. }
  74. html.dark{
  75. .custom-component{
  76. // background: #424243;
  77. }
  78. }
  79. </style>