admin管理员组文章数量:1301514
I'm having an array of elements in vuejs
, I've some data manipulation with them Like I've a select dropdown which shows the pany information and each pany information has a tag. Tags are of one sub level, I've joined both the tags as one and stored in database, whenever I select the parent pany I want these tags to be selected, I mean it should have class btn-warning
and rest all to be btn-primary
don't be confused with other select, there options are ing from the filter of first select
So suppose my tag data value is: Investor-Mutual fund
, it should split up and Investor
button should be selected and Mutual Fund
button should have class of btn-primary
and this should be changeable only with the select list only
Here's my code pen:
This will give you idea what I'm trying to do. Guide me
I'm having an array of elements in vuejs
, I've some data manipulation with them Like I've a select dropdown which shows the pany information and each pany information has a tag. Tags are of one sub level, I've joined both the tags as one and stored in database, whenever I select the parent pany I want these tags to be selected, I mean it should have class btn-warning
and rest all to be btn-primary
don't be confused with other select, there options are ing from the filter of first select
So suppose my tag data value is: Investor-Mutual fund
, it should split up and Investor
button should be selected and Mutual Fund
button should have class of btn-primary
and this should be changeable only with the select list only
Here's my code pen: https://codepen.io/anon/pen/eWXPaK?editors=1010
This will give you idea what I'm trying to do. Guide me
Share edited May 25, 2017 at 16:39 Nitish Kumar asked May 25, 2017 at 16:17 Nitish KumarNitish Kumar 6,28622 gold badges87 silver badges159 bronze badges1 Answer
Reset to default 5I believe this is what you want.
if (!this.selectedCompanies.length > 0){
const str = this.model.data.find(d => d.name === newValue.label)
const [currentTag, selectedTag] = str.tag.split("-")
this.currentTag = currentTag
this.selectedTag = this.tags[this.currentTag].find(t => t.display === selectedTag)
}
Updated pen.
本文标签: vuejsHow to find elements in an array in vuejs or JavascriptStack Overflow
版权声明:本文标题:vue.js - How to find elements in an array in vuejs or Javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741676613a2391917.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论