index.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <div id="mouse">
  3. <div class="item" v-for="item of modelList"
  4. :style="'width:' + item.w + 'px;height:' + item.h + 'px; top:' + item.x + 'px;left:' + item.y + '; border: 1px solid #000;'">
  5. <el-input v-model="item.w" type="number"></el-input>
  6. <el-input v-model="item.h" type="number"></el-input>
  7. </div>
  8. </div>
  9. </template>
  10. <script>
  11. export default {
  12. data() {
  13. return {
  14. modelList: [
  15. ],
  16. showx: 0,
  17. showy: 0,
  18. showwidth: 0,
  19. showheight: 0,
  20. input: ''
  21. }
  22. },
  23. created() {
  24. },
  25. mounted() {
  26. this.queryDom()
  27. },
  28. methods: {
  29. // 监听鼠标点击事件
  30. queryDom() {
  31. document.addEventListener('click', this.querydata)
  32. },
  33. querydata(event) {
  34. if (this.modelList.length === 0) {
  35. this.modelList.push({
  36. x: 0,
  37. y: 0,
  38. w: event.clientX > 0 && event.clientX > 1920 ? 1920 : event.clientX,
  39. h: event.clientX > 0 && event.clientY > 1080 ? 1080 : event.clientY,
  40. })
  41. } else {
  42. this.modelList.map(item => {
  43. if (item.w !== event.clientX && item.w !== event.clientY) {
  44. this.modelList.push({
  45. x: 0,
  46. y: 0,
  47. w: event.clientX > 0 && event.clientX > 1920 ? 1920 : event.clientX,
  48. h: event.clientX > 0 && event.clientY > 1080 ? 1080 : event.clientY,
  49. })
  50. }
  51. })
  52. }
  53. }
  54. },
  55. }
  56. </script>
  57. <style lang="scss">
  58. html {
  59. width: 1920px;
  60. height: 1080px;
  61. overflow: hidden;
  62. }
  63. body {
  64. width: 100%;
  65. height: 100%;
  66. overflow: hidden;
  67. }
  68. </style>
  69. <style scoped lang="scss">
  70. #screen {
  71. width: 1920px;
  72. height: 1080px;
  73. overflow: hidden;
  74. position: relative;
  75. .item {
  76. position: absolute;
  77. width: 0px;
  78. height: 0px;
  79. top: 0px;
  80. left: 0px;
  81. }
  82. }
  83. </style>