language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

Props break when i define data in defineComponent

Open ardelan869 opened this issue 1 year ago • 3 comments

With data() defined image Without data() defined image

<script lang="ts">
import { defineComponent } from 'vue';
import { vmin } from '@/lib/css';
import ButtonWrapper from './ButtonWrapper.vue';

export default defineComponent({
  name: 'Selection',
  components: {
    ButtonWrapper
  },
  data() {
    return {
      user: {
        id: 123456,
        name: 'ARDELAN 🐈🧶',
        picture:
          'https://www.pcgamesn.com/wp-content/sites/pcgamesn/2022/12/gta-5-dlc-los-santos-drug-wars.jpg'
      }
    };
  },
  methods: {
    vmin
  },
  props: {
    page: {
      type: String,
      default: 'selection',
      validator: (value) => {
        return typeof value === 'string';
      }
    }
  }
});
</script>

ardelan869 avatar May 10 '24 03:05 ardelan869

It also shows an error when i use the component in another one image

ardelan869 avatar May 10 '24 03:05 ardelan869

https://github.com/vuejs/core/issues/9296

so1ve avatar May 10 '24 04:05 so1ve

vuejs/core#9296

This issue isn't similar. My problem is that all the props become unknown when i define them like this and use data()

props: {
  prop: {
      type: String,
      default: 'selection',
      validator: (value) => {
        return typeof value === 'string';
      }
  }
}

but it works when i use them like this

props: {
  prop: String
}

This Issue comes from the Plugin

ardelan869 avatar May 10 '24 21:05 ardelan869