vue3 send a class into a component as a prop

 <script setup>

import { ref, computed } from "vue";

const props = defineProps(["link", "loading", "type", "propClass", "disabled"]);

const btnClass = computed(() => ({
  btn: true,
  "btn-secondary": props.type === "secondary",
  "btn-tertiary": props.type === "tertiary",
  "btn-outlined": props.type === "outlined",
  "btn-outlined-secondary": props.type === "outlined-secondary",
  "btn-outlined-tertiary": props.type === "outlined-tertiary",
  "btn-text": props.type === "text",
  "btn-text-secondary": props.type === "text-secondary",
  "btn-text-tertiary": props.type === "text-tertiary",
  [props.propClass]: props.propClass ? true : false,
}));
</script>

留言

此網誌的熱門文章

《Clean Code 2: Vue 3 檔案/資料夾結構》

[Laravel][ATOMIC] DB::transaction, DB::beginTransaction

[laravel 9] rename project