How to get Vue component data when setup using script
P粉392861047
P粉392861047 2024-01-16 11:41:21
0
1
356

I need to rewrite This code

export default Vue.extend<Props>({
  functional: true,
  render(h, { props, slots, data }) {
    const { href, external, target, type, button } = props;
    const slot = slots().default;
    console.log(data);
    ....

To Vue 3 combination script settings, So I managed to get

<script setup lang="ts">
 import {h, useSlots} from 'vue';
 const props = defineProps<Props>();
 const slots = useSlots();
 ...

But how do I get the data? Start with this part -> render(h, { props, slot, data }) {

The data should contain domProps if there is such..etc

console.log(data);

{
    {                                                                                                                                                                                                                                   
  attrs: {
    target: '_self',
    href: 'https://example.com',
    button: true
  },
  class: [
    'X-button',
    {
      'X-button--': false,
      'X-button--size-auto': true
    }
  ]
}

Thanks in advance

P粉392861047
P粉392861047

reply all(1)
P粉707235568

If you still need this,

useSlots().default() Returns slot data, including DOM attributes.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template