Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Props break when i define data in defineComponent #4363

Closed
ardelan869 opened this issue May 10, 2024 · 3 comments
Closed

Props break when i define data in defineComponent #4363

ardelan869 opened this issue May 10, 2024 · 3 comments

Comments

@ardelan869
Copy link

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
Copy link
Author

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

@so1ve
Copy link
Member

so1ve commented May 10, 2024

vuejs/core#9296

@ardelan869
Copy link
Author

ardelan869 commented May 10, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants