Feeling like I'm losing it, this should be really simple but it's not working...
The idea is that when the link is clicked, the display property toggles between true and false. However, it's not working as expected.
Vue.component('dropdown', {
props: [ 'expanded' ],
data: function() {
return {
display: !!(this.expanded)
}
},
template: '<div><transition name="expand"><slot :display="display"></slot></transition></div>'
});
window.app = new Vue({
el: '#app'
});
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<div id="app">
<dropdown>
<div slot-scope="{ display }">
<a href="javascript:void(0)" @click="display = !display">Toggle {{ display }}</a>
<div v-if="display">
Dropdown content
</div>
</div>
</dropdown>
</div>
Edit:
Updated code, I can't believe I missed that, I did in fact have the click event set to display = !display
. But still, if you try clicking the button, you'll see that it doesn't change to true either...