Soduko.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <!-- -->
  2. <template>
  3. <div class="Big-Book-prev-Textdes Sudoku" v-if="curQue">
  4. <div class="item-box">
  5. <div :class="['item']" v-for="(item,index) in curQue.option" :key="index">
  6. <div v-for="(items,indexs) in item" :key="indexs" :class="[indexs%3==2?'noBorder':'',indexs>5?'noBorder-bottom':'']">
  7. <span v-if="items.isHint">
  8. {{items.value}}
  9. </span>
  10. <input v-else v-model="soduko[index][indexs]" maxlength="1" @input="changeNumber(soduko[index][indexs],index,indexs)" @blur="handleCheck(index,indexs)">
  11. </div>
  12. </div>
  13. </div>
  14. </div>
  15. </template>
  16. <script>
  17. export default {
  18. components: {},
  19. props: ["curQue"],
  20. data() {
  21. return {
  22. soduko:[]
  23. };
  24. },
  25. computed: {},
  26. watch: {},
  27. //方法集合
  28. methods: {
  29. // 处理数据
  30. handleData(){
  31. let _this = this
  32. _this.soduko = []
  33. _this.curQue.option.forEach(item => {
  34. let arr = []
  35. item.forEach(items=>{
  36. if(items.isHint){
  37. arr.push(items.value)
  38. }else{
  39. arr.push('')
  40. }
  41. })
  42. _this.soduko.push(arr)
  43. });
  44. },
  45. changeNumber(item,index,indexs) {
  46. let value = item.replace(/[^\d]/g, "")
  47. this.$set(this.soduko[index],indexs,value)
  48. },
  49. // 校验输入内容是否已有
  50. handleCheck(index,indexs){
  51. },
  52. },
  53. //生命周期 - 创建完成(可以访问当前this实例)
  54. created() {
  55. this.handleData()
  56. },
  57. //生命周期 - 挂载完成(可以访问DOM元素)
  58. mounted() {},
  59. beforeCreate() {}, //生命周期 - 创建之前
  60. beforeMount() {}, //生命周期 - 挂载之前
  61. beforeUpdate() {}, //生命周期 - 更新之前
  62. updated() {}, //生命周期 - 更新之后
  63. beforeDestroy() {}, //生命周期 - 销毁之前
  64. destroyed() {}, //生命周期 - 销毁完成
  65. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  66. };
  67. </script>
  68. <style lang='scss' scoped>
  69. //@import url(); 引入公共css类
  70. .Big-Book-prev-Textdes{
  71. .item-box{
  72. display: flex;
  73. flex-flow: wrap;
  74. width: 544px;
  75. border-bottom: 1px solid #484848;
  76. border-right: 1px solid #484848;
  77. .item{
  78. display: flex;
  79. flex-flow: wrap;
  80. width: 181px;
  81. height: 181px;
  82. border-top: 1px solid #484848;
  83. border-left: 1px solid #484848;
  84. box-sizing: border-box;
  85. div{
  86. width: 60px;
  87. height: 60px;
  88. display: flex;
  89. justify-content: center;
  90. align-items: center;
  91. border-bottom: 1px solid #D1D1D1;
  92. border-right: 1px solid #D1D1D1;
  93. box-sizing: border-box;
  94. &.noBorder{
  95. border-right: none;
  96. }
  97. &.noBorder-bottom{
  98. border-bottom: none;
  99. }
  100. span{
  101. font-size: 20px;
  102. line-height: 150%;
  103. color: #32A5D8;
  104. font-family: 'robot';
  105. }
  106. input{
  107. width: 100%;
  108. height: 100%;
  109. border: none;
  110. outline: none;
  111. text-align: center;
  112. color: #000000;
  113. font-size: 20px;
  114. font-weight: 500;
  115. font-family: 'robot';
  116. }
  117. }
  118. }
  119. }
  120. }
  121. </style>