先講解決方案:
可以通過return 一個function來實現,在function中傳入想要傳給computed屬性的參數
<q-icon :name="getIcon(item.icon,index+1)" style="font-size:2em" @click="btnClicked(index+1)"/>
computed:{
getIcon: function(){
return function(iconName, tabIndex){
return `${this.tabNum===tabIndex ? '' : 'o_'}${iconName}`;
}
},
...mapState({
showSearchFriendDialog: 'showSearchFriendDialog',
showChangeAvatarDialog: 'showChangeAvatarDialog',
showCreateGroupDialog: 'showCreateGroupDialog',
user: 'user'
})
},
再講一下我遇到的問題:
vue的v-bind屬性傳入一個computed函數,當該函數帶有參數的時候, 瀏覽器報錯,當不帶有參數的時候正常執行
下面這樣解決: