CheckBoxModule.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <!-- -->
  2. <template>
  3. <div
  4. class="Big-Book-prev-Textdes CheckboxModule"
  5. v-if="curQue"
  6. :class="[isPhone ? 'CheckboxModule-phone' : '']"
  7. >
  8. <h2>{{ curQue.title }}</h2>
  9. <el-checkbox
  10. v-model="curQue.Bookanswer[index]"
  11. v-for="(item, index) in curQue.option"
  12. :key="index"
  13. :readonly="TaskModel == 'ANSWER'"
  14. >{{ item.con }}</el-checkbox
  15. >
  16. </div>
  17. </template>
  18. <script>
  19. export default {
  20. components: {},
  21. props: ["curQue", "TaskModel", "isPhone"],
  22. data() {
  23. return {
  24. userList: []
  25. };
  26. },
  27. computed: {},
  28. watch: {},
  29. //方法集合
  30. methods: {
  31. handleData() {
  32. let _this = this;
  33. let userList = [];
  34. _this.curQue.option.forEach(item => {
  35. userList.push(false);
  36. });
  37. if (!this.curQue.Bookanswer) {
  38. this.$set(this.curQue, "Bookanswer", userList);
  39. }
  40. }
  41. },
  42. //生命周期 - 创建完成(可以访问当前this实例)
  43. created() {
  44. this.handleData();
  45. },
  46. //生命周期 - 挂载完成(可以访问DOM元素)
  47. mounted() {},
  48. beforeCreate() {}, //生命周期 - 创建之前
  49. beforeMount() {}, //生命周期 - 挂载之前
  50. beforeUpdate() {}, //生命周期 - 更新之前
  51. updated() {}, //生命周期 - 更新之后
  52. beforeDestroy() {}, //生命周期 - 销毁之前
  53. destroyed() {}, //生命周期 - 销毁完成
  54. activated() {} //如果页面有keep-alive缓存功能,这个函数会触发
  55. };
  56. </script>
  57. <style lang="scss" scoped>
  58. //@import url(); 引入公共css类
  59. .CheckboxModule {
  60. width: 100%;
  61. margin: 0;
  62. h2 {
  63. margin: 8px 0;
  64. font-size: 16px;
  65. line-height: 150%;
  66. color: #000000;
  67. }
  68. .el-checkbox {
  69. width: 100%;
  70. margin: 4px 0;
  71. }
  72. }
  73. </style>
  74. <style lang="scss">
  75. .CheckboxModule {
  76. .el-checkbox__label,
  77. .el-checkbox__input.is-checked + .el-checkbox__label {
  78. color: #000000;
  79. font-size: 16px;
  80. line-height: 1.5;
  81. font-weight: normal;
  82. }
  83. .el-checkbox__inner {
  84. border-color: #4d91f6;
  85. }
  86. }
  87. .CheckboxModule-phone {
  88. .el-checkbox {
  89. display: flex;
  90. align-items: flex-start;
  91. }
  92. .el-checkbox__label {
  93. white-space: normal;
  94. word-break: break-word;
  95. }
  96. .el-checkbox__input {
  97. margin-top: 5px;
  98. }
  99. }
  100. </style>