2👍
✅
Your code seems a little confused, your is_open
is in your component but you are trying to access it in the parent. You just need to make sure this logic is contained inside your component. The easiest way is to simply place an event on the relevant element in your component template:
<template>
<div>
<!-- Toggle when button is clicked-->
<button @click="is_open=!is_open">
Open Me!
</button>
<span v-show="is_open">
I'm Open!
</span>
</div>
</template>
Here’s the JSFiddle: https://jsfiddle.net/ytw22k3w/
0👍
Because u used is_open property in ‘#app instance’ but u didnt declare in it,u decladed in ‘m-panel component’ which has no relation with it.Try something like this can avoid it.
new Vue({
el:'#app',
data:{
is_open:''
}
})
👤胡亚雄
Source:stackexchange.com