마크업개발자분이 Button 컴포넌트 개발 중에 props href가 있으면 router-link로 element를 변경하고 싶으시다는 요청이 있었습니다.
<template>
<component
:is="componentType"
:to="href"
...
</component>
</template>
<script lang="ts">
import Vue from "vue";
export default Vue.extend({
props: {
href: {
type: String,
},
...
},
computed: {
componentType() {
return this.href ? "router-link" : "button";
},
},
});
</script>