我有两个组件dashboard.vue(父级)和displaybooks.vue(子级)。在子组件中,我有一个数组addedbooks:[]当用户单击AddtoBag按钮时,它应该增加,当用户单击AddtoBag按钮时,它应该减少,直到现在为止,它工作正常,现在我的要求是addedbooks.length(数组长度)应该从displaybooks.vue传输到dashboard.vue组件。如何实现这一点请帮助我 Dashboard.vue
```
<ul class="nav navbar-nav navbar-right" id="right-bar">
<li><a> <i class="far fa-user"></i></a></li>
<p class="profile-content">profile</p>
<li><a><i class="fas fa-cart-plus"></i></a></li>
<p class="cart-content">cart</p>
</ul>
</div>
<div class="mid-body">
<h6>Books<span class="items">(128items)</span></h6>
<select class="options" @change="applyOption">
<option disabled value="">Sort by relevance</option>
<option value="HighToLow">price:High to Low</option>
<option value="LowToHigh">price:Low to High</option>
</select>
</div>
<div v-if="flam==false">
<h2>Hello</h2>
</div>
<DisplayBooks v-show="flag==='noOrder'" />
<sortBooksLowtoHigh v-show="flag==='lowToHigh'" />
<sortBooksHightoLow v-show="flag==='highToLow'" />
`DisplayBooks.vue`
1条答案
按热度按时间bf1o4zei1#
观察阵列更改并将其长度发送到父阵列:
displaybooks.vue
Jmeter 板