Commit 86fff574 authored by JinWei's avatar JinWei

feat: 添加正确选项的key

parent ff02c222
10.24.1
\ No newline at end of file
......@@ -5,8 +5,10 @@
# You can see what browsers were selected by your queries by running:
# npx browserslist
> 0.5%
last 2 versions
Firefox ESR
not dead
not IE 9-11 # For IE 9-11 support, remove 'not'.
\ No newline at end of file
# Targeting modern browsers only — disables ES5 differential loading bundle, speeds up build significantly.
last 2 Chrome versions
last 2 Firefox versions
last 2 Edge versions
last 2 Safari versions
last 2 iOS versions
not IE 9-11
\ No newline at end of file
......@@ -48,6 +48,17 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
if (!this.item.questionArr) {
this.item.questionArr = [];
}
this.item.questionArr.forEach(q => {
if (q.optionArr) {
this.syncOptionKeys(q.optionArr);
}
});
}
syncOptionKeys(optionArr: any[]) {
optionArr.forEach((option, index) => {
option.key = this.getOptionLabel(index);
});
}
addQuestion() {
......@@ -73,7 +84,7 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
}
getOptionLabel(index: number): string {
const labels = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'];
const labels = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N'];
return labels[index] !== undefined ? labels[index] : String(index + 1);
}
......@@ -82,11 +93,13 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
ques.optionArr = [];
}
ques.optionArr.push({});
this.syncOptionKeys(ques.optionArr);
this.save();
}
deleteOptionBtnClick(arr, i) {
arr.splice(i, 1);
this.syncOptionKeys(arr);
this.save();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment