1

我正在使用 Onsen UI 框架来构建一个移动应用程序(不是原生的,只是 HTML5)。我有一个 JS 测验,其中包括用于回答问题的单选按钮。目前,答案的按钮和文本样式是“普通标准”的,但我想要 Onsen UI 的。

如何在 JS 中集成 Onsen UI 框架?

我认为这与这部分有关:

answers.push(
    `<label>
<input type="radio" name="question${questionNumber}" value="${letter}">
${letter} :
${currentQuestion.answers[letter]}
</label>`

这是完成的测验。

(function() {
function buildQuiz() {
  const output = [];
  myQuestions.forEach((currentQuestion, questionNumber) => {
    const answers = [];
    for (var letter in currentQuestion.answers) {
      answers.push(
        `<label>
    <input type="radio" name="question${questionNumber}" value="${letter}">
    ${letter} :
    ${currentQuestion.answers[letter]}
  </label>`
      );
    }
    output.push(
      `<div class="question"> ${currentQuestion.question} </div>
<div class="answers"> ${answers.join("")} </div>`
    );
  });
  quizContainer.innerHTML = output.join("");
}
const quizContainer = document.getElementById("quiz");
const myQuestions = [{
    question: "Who is the strongest?",
    answers: {
      a: "Superman",
      b: "The Terminator",
      c: "Waluigi, obviously"
    },
    correctAnswer: "c"
  },
  {
    question: "What is the best site ever created?",
    answers: {
      a: "SitePoint",
      b: "Simple Steps Code",
      c: "Trick question; they're both the best"
    },
    correctAnswer: "c"
  },
  {
    question: "Where is Waldo really?",
    answers: {
      a: "Antarctica",
      b: "Exploring the Pacific Ocean",
      c: "Sitting in a tree",
      d: "Minding his own business, so stop asking"
    },
    correctAnswer: "d"
  },
];
4

0 回答 0