[Vuejs]-How to give a prop a parameter vue?

0👍

usually when you get such question, you can take a quick look at the package source code.

the collapsed prop accepts a boolean value. your parent component will look like:

<template>
  <sidebar-menu :menu="menu" :collapsed="myCollapse"/>
</template>
<script>
  export default{
    data(){
      return {
        myCollapse:false
      }
    }
  }
</script>

then, every time you change your own mycollapse property, the sidebar-menu component will react to that change.

0👍

In this case you would need to pass the collapsed value as a prop to the sidebar-menu

<sidebar-menu :menu="menu" :collapsed="collapsed"/>

if that doesn’t help adding some more code to make the example clearer would be better.

Leave a comment