JavaScript:修改动态创建按钮的颜色/大小等
P粉085689707
P粉085689707 2024-02-17 14:35:03
0
1
306

我在 vuejs 中创建了动态按钮,其中每个按钮代表问题的不同答案。

我的目标是:当我回答错误时,正确的选项会以绿色突出显示,直到显示下一个问题。

是否还可以使用 CSS 更改这些“BaseButtons”的其他设置?我怎样才能做到这一点?

<template>
  <div class="container-botoes">
     <BaseButton class="optionsButtons" 
     v-for="options in optionsAnswers" 
     :key="options.id" @click="handleAnswer(options)">
       {{options.ans}}
     </BaseButton>
  </div>
</template>
methods:{
  handleAnswer(options){
    if (options.id === this.correctAnswer){
      this.playerHit = true;
    }
    else {
      this.opponentHit = true;
      
    }
    this.nextquestion();
  },

P粉085689707
P粉085689707

全部回复(1)
P粉007288593

一种选择是使用您需要的样式创建 css 类,然后根据您的条件将它们附加到 BaseButton 组件

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!