Home > Blockchain >  How to access prop value inside another prop in vue 3 script setup?
How to access prop value inside another prop in vue 3 script setup?

Time:12-15

My code

 const props = defineProps({
 isOpen: {
    type: Boolean,
    default: true,
    default: false,
  },
 closeModal: {
    type: Function,
    required: true,
  },
 closeModal2: {
    type: Function,
    //  access and change the value of the prop => props.isOpen
  },
});

I want to get and change the value of isOpen in closeModel2 prop. Is it possible? If yes then how can we achieve it?

CodePudding user response:

You can't. What you can do is emit an event from that component to the parent component which controls the isOpen reactive value and change it there.

something like this: https://sfc.vuejs.org/#eNqFkU1vgzAMhv KlUtbqZA7o9U tPN22G3ZgYJZ00ESxaE7IP77HChoX9pusWM/tt 3FzfOpecORSZyKr12AQhD5/bK6NZZH DuqJsKam9bUCKVYxg7lLhaanqP9TDXzH8AypTWUABNDw4N7IDL1sF3uOHvXE7zeBIHAVvXFAE5AsinmZmmxHLjTomJoARcl40lXDLMrIuGeKDkzlwuGLEV025JW7j0RNbwhf241OWDlMhgzMTcuHTGj2MIjjIpqS7jlSdKrX V/Ep9Z4JuMUVqk4O374SewUpsPzEkJ8/oE4 mQo/ L a30h/ciB2UGfiURfRfbKqw1gYfvXW0Hs ZlMng1toGCxZ3iHLPXmCrA6s2dd1zQOvn1Sjq6uU/Ww5dCNZED3T5xh5E1vrSvFFi/4RNA67giwIEGzecredo9CmXE2PiVfq87/u5ZhhyGTNffRw AKBw68Q=

  • Related