康巴易测肤/伤疤uniapp小程序类
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.vue 2.3KB

1 kuukausi sitten
1 kuukausi sitten
1 kuukausi sitten
1 kuukausi sitten
1 kuukausi sitten
1 kuukausi sitten
1 kuukausi sitten
1 kuukausi sitten
1 kuukausi sitten
1 kuukausi sitten
1 kuukausi sitten
1 kuukausi sitten
1 kuukausi sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <view class="container">
  3. <!-- 问卷题目 -->
  4. <view class="question" v-if="currentQuestion">
  5. <text class="question-text">{{ currentQuestion.text }}</text>
  6. <view class="options">
  7. <u-radio-group v-model="currentAnswer">
  8. <u-radio v-for="(option, index) in currentQuestion.options" :key="index" :name="option">
  9. {{ option }}
  10. </u-radio>
  11. </u-radio-group>
  12. </view>
  13. </view>
  14. <!-- 上一步和下一步按钮 -->
  15. <view class="buttons">
  16. <u-button type="primary" @click="prevQuestion" :disabled="currentIndex === 0">
  17. 上一步
  18. </u-button>
  19. <u-button type="primary" @click="nextQuestion" :disabled="currentIndex === questions.length - 1">
  20. 下一步
  21. </u-button>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. questions: [
  30. {
  31. text: '1. 您的性别是?',
  32. options: ['男', '女']
  33. },
  34. {
  35. text: '2. 您的年龄是?',
  36. options: ['18岁以下', '18-25岁', '26-35岁', '36岁以上']
  37. },
  38. {
  39. text: '3. 您的职业是?',
  40. options: ['学生', '上班族', '自由职业', '其他']
  41. }
  42. ],
  43. currentIndex: 0,
  44. currentAnswer: ''
  45. };
  46. },
  47. computed: {
  48. currentQuestion() {
  49. return this.questions[this.currentIndex];
  50. }
  51. },
  52. methods: {
  53. prevQuestion() {
  54. if (this.currentIndex > 0) {
  55. this.currentIndex--;
  56. this.currentAnswer = ''; // 清空当前答案
  57. }
  58. },
  59. nextQuestion() {
  60. if (this.currentIndex < this.questions.length - 1) {
  61. this.currentIndex++;
  62. this.currentAnswer = ''; // 清空当前答案
  63. }
  64. }
  65. }
  66. };
  67. </script>
  68. <style scoped>
  69. .container {
  70. padding: 20px;
  71. }
  72. .question-text {
  73. font-size: 18px;
  74. margin-bottom: 20px;
  75. }
  76. .options {
  77. margin-top: 10px;
  78. }
  79. .buttons {
  80. margin-top: 20px;
  81. display: flex;
  82. justify-content: space-between;
  83. }
  84. </style>