简体   繁体   English

如何使用 Vuejs 中的计算属性设置匹配的数组值和条件?

[英]How to set matching array values with conditions using computed property in Vuejs?

 <div> <div v-for="box in boxes":key="box.id"> <BaseAccordian> <template v-slot:title>{{ box.name }}</template> <template v-slot:content> <div v-for="paint in paints":key="paint.id" class="line"> <div> <StatusComponent:box="box":paint="paint":matchingdata="matchingdata" /> <,--only status like ok,not, medium to be printed on line accordingly --> </div> </div> </template> </BaseAccordian> </div> </div>

How to set matching array values in Vuejs?如何在 Vuejs 中设置匹配的数组值?

In my code, I have 3 arrays called, boxes, paints, matchingdata .在我的代码中,我有 3 个 arrays 被称为box、paints、matchingdata By using those arrays, i want to perfome the functionality.通过使用那些 arrays,我想执行该功能。

After the checkbox is clicked, At present i am showing some information related to paints array单击复选框后,目前我正在显示一些与油漆数组相关的信息

So i need to set the matching array value condition here like.所以我需要在这里设置匹配的数组值条件。

Do you want to update matchingdata inside your StatusComponent ?您想更新StatusComponent中的matchingdata数据吗? This can be done by methods.这可以通过方法来完成。 There is a relevant example in the official vue documentation https://v3.vuejs.org/guide/list.html#v-for-with-a-component . vue 官方文档https://v3.vuejs.org/guide/list.html#v-for-with-a-component中有相关示例。

you don't set matching array values with conditions using computed property in Vuejs, you can use method replace computed property你没有在 Vuejs 中使用计算属性设置匹配的数组值,你可以使用方法替换计算属性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM