Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· OpenAIAi2 WildChat-4.8M (AI2)

v-bind:style="[ myactiveid === item.pkgProjectSkuID? background-color:red]"这段代码有问题嘛

  1. User

    v-bind:style="[ my_active_id === item.pkgProjectSkuID? background-color:red]"这段代码有问题嘛

  2. Assistant

    是的,这段代码存在问题。

    在v-bind:style中,你需要传递一个对象,该对象包含要应用的内联样式。

    正确的代码应该是:

    v-bind:style="{ 'background-color': my_active_id === item.pkgProjectSkuID ? 'red' : '' }"
    

    这样,当my_active_id和item.pkgProjectSkuID相等时,background-color属性将被设置为红色;否则,将没有背景颜色。