通过注释一行代码 开启关闭一个div的css样式 - 开发调试技巧

通过注释一行代码 开启关闭一个div的css样式 - 开发调试技巧

需求:开发的时候,我需要对页面的某个样式反复开关,但是html不能通过注释来开关,所以可以在div的上面加一个js
但是vue的template里面不能加script,需要加component

重点代码 不写v-bind vscode有红色波浪

<component v-bind:is="'script'">
      document.getElementById("bigWrapId").style.marginLeft = "-1200px";
    </component>

整体代码

<v-scale-screen
    :autoScale="false"
    width="1920"
    height="1080"
    :boxStyle="{
      backgroundColor: '',
    }"
  >
    <!-- margin-left: -1200px; -->
    <component v-bind:is="'script'">
      document.getElementById("bigWrapId").style.marginLeft = "-1200px";
    </component>
    <div id="bigWrapId" style="width: 1920px; height: 1080px">
      <bigScreen></bigScreen>
    </div>
  </v-scale-screen>
posted @ 2024-09-14 10:05  彭成刚  阅读(3)  评论(0编辑  收藏  举报