File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 11<script setup lang="ts">
2+ import vw from ' @/utils/inline-px-to-vw'
3+
24defineProps ({
35 paddingT: {
46 type: Number ,
@@ -14,7 +16,7 @@ defineProps({
1416<template >
1517 <main
1618 class =" absolute left-0 h-full w-full overflow-y-auto"
17- :style =" `padding-top: ${paddingT}px ; padding-left: ${paddingX}px ; padding-right: ${paddingX}px `"
19+ :style =" `padding-top: ${vw( paddingT)} ; padding-left: ${vw( paddingX)} ; padding-right: ${vw( paddingX)} `"
1820 >
1921 <slot />
2022 </main >
Original file line number Diff line number Diff line change 1+ import { round } from 'lodash-es'
2+
3+ // 设计稿的宽度
4+ const width = 375
5+
6+ /**
7+ * vw 转换
8+ * @param {number } n
9+ */
10+ export default function vw ( n : number ) {
11+ if ( n === 0 )
12+ return n
13+ const vwN = round ( n * 100 / width , 3 )
14+ return `${ vwN } vw`
15+ }
You can’t perform that action at this time.
0 commit comments