unitResult.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <uni-popup ref="popupRef" :animation="false" :is-mask-click="false"
  3. mask-background-color="rgba(255, 255, 255, 0.6);" class="ezy-popup-width-all">
  4. <view>
  5. <!-- 导航 -->
  6. <view @click="handleBack">返回</view>
  7. <view>
  8. <view>图</view>
  9. <view> 单元测试已完成 </view>
  10. </view>
  11. <view>
  12. <view>
  13. <view>{{data.right}}</view>
  14. <view>正确</view>
  15. </view>
  16. <view>
  17. <view>{{data.wrong}}</view>
  18. <view>错误</view>
  19. </view>
  20. </view>
  21. <view>
  22. <button @click="handleRestart">重新测试</button>
  23. <button @click="handleCheckAnswer">查看答案</button>
  24. </view>
  25. </view>
  26. </uni-popup>
  27. </template>
  28. <script setup>
  29. import {
  30. ref,
  31. reactive
  32. } from "vue";
  33. const popupRef = ref(null)
  34. const data = reactive({
  35. right: 0,
  36. wrong: 0,
  37. })
  38. const emits = defineEmits(['check-answer', 'do-replay'])
  39. function handleRestart() {
  40. emits('do-replay')
  41. }
  42. function handleCheckAnswer() {
  43. emits('check-answer')
  44. }
  45. function showPopup(options) {
  46. data.right = options.right;
  47. data.wrong = options.wrong;
  48. popupRef.value.open();
  49. }
  50. function closePopup() {
  51. popupRef.value.close();
  52. }
  53. function handleBack() {
  54. closePopup();
  55. }
  56. defineExpose({
  57. showPopup,
  58. closePopup
  59. })
  60. </script>
  61. <style>
  62. </style>