부모 컴포넌트에서 width, height를 받아 자식 컴포넌트에서는 이를 바탕으로 너비와 높이를 설정해주려 했다.
그러면 동적으로 class 바인딩을 해줘야했다.
<div :class="`w-${width} h-${height}`">
</div>
위와 같이 설정해주면 class값은 있으나 반영되지는 않는다. 즉, width : 400, height: 100을 해주어도 동작하지 않는다는 의미이다.
왜 그럴까
Content Configuration - Tailwind CSS


props 로 전달받은 경우에는 따로 객체를 만들어서 진행해야된다는 것을 보여준다.style 바인딩을 활용해서 적용하였다.<template>
<div :style="{ width: `${width}px`, height: `${height}px`, backgroundColor: 'blue' }">
스타일 박스
</div>
</template>
<script setup>
defineProps({
width: Number,
height: Number,
});
</script>