Skip to content

Commit

Permalink
优化检查选项是否选择的方式
Browse files Browse the repository at this point in the history
  • Loading branch information
Super12138 committed Sep 28, 2024
1 parent b176a6d commit 95e0b2e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'mdui/components/radio.js';

import type { Button } from 'mdui/components/button.js';
import type { LinearProgress } from 'mdui/components/linear-progress.js';
import type { RadioGroup } from 'mdui/components/radio-group.js';
import type { TopAppBarTitle } from 'mdui/components/top-app-bar-title.js';

import '@mdui/icons/arrow-back--outlined.js';
Expand Down Expand Up @@ -138,16 +137,16 @@ document.addEventListener('testPageLoaded', async () => {
};

function checkQuestionChecked(id: number) {
const radioGroup: RadioGroup = document.querySelector(`#questions-${id}`)!;
if (radioGroup.value) {
const checkQuestion = questions[id - 1].html.querySelector('mdui-radio-group')!;
if (checkQuestion.value) {
nextBtn.disabled = false;
} else {
nextBtn.disabled = true;
const radioChangeListener = () => {
nextBtn.disabled = false;
radioGroup.removeEventListener('change', radioChangeListener);
checkQuestion.removeEventListener('change', radioChangeListener);
};
radioGroup.addEventListener('change', radioChangeListener);
checkQuestion.addEventListener('change', radioChangeListener);
}
}

Expand Down

0 comments on commit 95e0b2e

Please sign in to comment.