We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A vue page that loops through multiple quill components cannot get the quill instance of the current operation
components VueQuillEditor.vue
baseQuestion.vue
<!-- 选项 start --> <el-row> <el-form-item v-if="questiondata.questionTypeId==='1' || questiondata.questionTypeId==='2'" label="选项" class="choice-el-form-item" prop="choiceList"> <template v-for="(item, index) in optionsAll"> <div :key="index" class="choice-item"> <label slot="label">{{ String.fromCharCode(64 + (index + 1)) }}</label> <vue-quill-editor :value="questiondata.choiceList[index].value" :callback-param="index" @quillContentInput="optionQuillContent"></vue-quill-editor> <el-button v-if="index > 1" class="mini-btn" type="danger" icon="el-icon-delete" @click.prevent="removeOptionItem(index)" circle></el-button> </div> </template> </el-form-item> <el-form-item v-if="questiondata.questionTypeId==='1'||questiondata.questionTypeId==='2'" class="little-item"> <el-button type="primary" class="margin-bottom-20" @click="addItem" plain>添加选项</el-button> </el-form-item> </el-row> <!-- 选项 end --> <!--正确答案 start --> <el-form-item v-if="questiondata.questionTypeId==='1'" label="正确答案" prop="questionAnswer"> <el-select v-model="questiondata.questionAnswer" placeholder="请选择正确答案"> <el-option v-for="(item, index) in optionsAll" :key="index" :label="String.fromCharCode(64 + (index + 1))" :value="String.fromCharCode(64 + (index + 1))" /> </el-select> </el-form-item> <el-form-item v-else-if="questiondata.questionTypeId==='2'" label="正确答案" prop="multiQuestionAnswer"> <el-checkbox-group v-model="questiondata.multiQuestionAnswer" class="multi-checkbox"> <el-checkbox v-for="(item, index) in optionsAll" :key="index" :label="String.fromCharCode(64 + (index + 1))" @change="refreshElement" >{{ String.fromCharCode(64 + (index + 1)) }}</el-checkbox> </el-checkbox-group> </el-form-item> <el-form-item v-else-if="questiondata.questionTypeId==='3'" label="正确答案" prop="questionAnswer"> <el-select v-model="questiondata.questionAnswer" placeholder="请选择正确答案"> <el-option label="正确" value="1" /> <el-option label="错误" value="0" /> </el-select> </el-form-item> <el-form-item v-else-if="questiondata.questionTypeId >= '4' && questiondata.questionTypeId <= '7'" label="参考答案" prop="questionAnswer"> <vue-quill-editor :value="questiondata.questionAnswer" @quillContentInput="answerQuillContent"></vue-quill-editor> </el-form-item> <!--正确答案 end -->
// 删除选项 removeOptionItem(index) { if (index !== -1) { let delChoice = this.questiondata.choiceList.splice(index, 1)[0] if (this.questiondata.questionTypeId === '1') { // 单选题,删除选项时,如果被删除的选项正好是答案项,则同时把答案置空 if (this.questiondata.questionAnswer === delChoice.id) { this.questiondata.questionAnswer = '' } } // 多选题,删除选项时,如果被删除的选项正好是答案项,则同时删除对应的答案选项 if (this.questiondata.questionTypeId === '2') { this.questiondata.multiQuestionAnswer.remove(delChoice.id) } // 重置选项列表编号:A,B,C..., 如:[{id:A,value:''}, {id:B,value:''}, {id:C,value:''}, {id:D,value:''}] this.questiondata.choiceList.forEach((item, index) => { item.id = String.fromCharCode(64 + (index + 1)) }) // 强制刷新 this.$forceUpdate() } }, // 增加选项 addItem() { if (this.questiondata.choiceList.length >= 6) { return this.$modal.msgWarning('最多只能添加6个选项') } else { let val = '' if (this.questiondata.choiceList.length === 2) { val = '2' } else if (this.questiondata.choiceList.length === 3) { val = '3' } else if (this.questiondata.choiceList.length === 4) { val = '4' } else if (this.questiondata.choiceList.length === 5) { val = '5' } this.questiondata.choiceList.push({ id: val, value: '' }) // 强制刷新 this.$forceUpdate() } }, quillContent(quillContent) { this.questiondata.title = quillContent }, optionQuillContent(quillContent, callbackParam) { this.questiondata.choiceList[callbackParam].value = quillContent }, answerQuillContent(quillContent) { this.questiondata.questionAnswer = quillContent }
}
} </script>
addQuestion.vue
package.json { "name": "igrandsoft", "version": "1.0.0", "description": "中环宏图管理系统", "author": "中环宏图产品组", "license": "MIT", "scripts": { "dev": "vue-cli-service serve", "build:prod": "vue-cli-service build", "build:stage": "vue-cli-service build --mode staging", "preview": "node build/index.js --preview" }, "husky": { "hooks": { "pre-commit": "lint-staged" } }, "lint-staged": { "src/**/*.{js,vue}": [ "eslint --fix", "git add" ] }, "keywords": [ "vue", "admin", "dashboard", "element-ui", "boilerplate", "admin-template", "management-system" ], "repository": { "type": "git", "url": "[email protected]:igrandsoft-web/igrandsoft-web-admin.git" }, "dependencies": { "@riophae/vue-treeselect": "0.4.0", "ali-oss": "^6.16.0", "axios": "0.24.0", "clipboard": "2.0.8", "core-js": "3.19.1", "echarts": "4.9.0", "element-ui": "2.15.6", "file-saver": "2.0.5", "fuse.js": "6.4.3", "highlight.js": "10.7.3", "js-beautify": "1.13.0", "js-cookie": "3.0.1", "jsencrypt": "3.2.1", "nprogress": "0.2.0", "qrcodejs2": "0.0.2", "quill": "1.3.7", "screenfull": "5.0.2", "sortablejs": "1.10.2", "vue": "2.6.12", "vue-count-to": "1.0.13", "vue-cropper": "0.5.5", "vue-meta": "2.4.0", "vue-quill-editor": "^3.0.6", "vue-router": "3.4.9", "vuedraggable": "2.24.3", "vuex": "3.6.0" }, "devDependencies": { "@babel/eslint-parser": "^7.18.2", "@babel/eslint-plugin": "^7.17.7", "@vue/cli-plugin-babel": "4.4.6", "@vue/cli-plugin-eslint": "4.4.6", "@vue/cli-service": "4.4.6", "babel-eslint": "^10.1.0", "chalk": "4.1.0", "connect": "3.6.6", "eslint": "7.15.0", "eslint-plugin-vue": "7.2.0", "lint-staged": "10.5.3", "quill-image-extend-module": "^1.1.2", "runjs": "4.4.2", "sass": "1.32.13", "sass-loader": "10.1.1", "script-ext-html-webpack-plugin": "2.1.5", "svg-sprite-loader": "5.1.1", "vue-template-compiler": "2.6.12" }, "browserslist": [ "> 1%", "last 2 versions" ], "engines": { "node": ">=8.9", "npm": ">= 3.0.0" } }
npm
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
A vue page that loops through multiple quill components cannot get the quill instance of the current operation
Reproduction
components
VueQuillEditor.vue
baseQuestion.vue
}
}
<style lang="scss" scoped> .mini-btn { height: 30px; width: 30px; padding: 0 2px; margin: 9px 0 0 8px; } </style></script>
addQuestion.vue
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: