Skip to content

Commit

Permalink
Fixed slot usage in ModelLink.
Browse files Browse the repository at this point in the history
Moved to the composition API to ease access to the slots. Must still be tested with other things than tags.

Refs #156
  • Loading branch information
The4thLaw committed Mar 19, 2024
1 parent 177c608 commit edbf1f3
Showing 1 changed file with 23 additions and 33 deletions.
56 changes: 23 additions & 33 deletions source/demyo-vue-frontend/src/components/ModelLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,46 +28,36 @@
</span>
</template>

<script>
export default {
name: 'ModelLink',
<script setup>
import { computed, useSlots } from 'vue';
props: {
model: {
type: null,
required: true
},
view: {
type: String,
required: true
},
const props = defineProps({
model: {
type: null,
required: true
},
commaSeparated: {
type: Boolean,
default: true
},
view: {
type: String,
required: true
},
cssClass: {
type: String,
default: ''
}
commaSeparated: {
type: Boolean,
default: true
},
computed: {
isArray() {
return Array.isArray(this.model)
},
cssClass: {
type: String,
default: ''
}
})
hasDefaultSlot() {
return !!this.$scopedSlots.default
},
const isArray = computed(() => Array.isArray(props.model))
const length = computed(() => isArray.value ? props.model.length : 1)
length() {
return this.isArray ? this.model.length : 1
}
}
}
const slots = useSlots()
const hasDefaultSlot = computed(() => !!slots.default)
</script>

<style lang="less">
Expand Down

0 comments on commit edbf1f3

Please sign in to comment.