康巴易测肤/伤疤uniapp小程序类
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

120 rindas
2.4KB

  1. <template>
  2. <view class="info">
  3. <view class="main">
  4. <u--form
  5. labelPosition="left"
  6. :model="model1"
  7. :rules="rules"
  8. ref="uForm"
  9. >
  10. <u-form-item
  11. label="姓名"
  12. prop="userInfo.name"
  13. borderBottom
  14. ref="item1"
  15. >
  16. <u--input
  17. v-model="model1.userInfo.name"
  18. border="none"
  19. ></u--input>
  20. </u-form-item>
  21. <u-form-item
  22. label="性别"
  23. prop="userInfo.sex"
  24. borderBottom
  25. @click="showSex = true"
  26. ref="item1"
  27. >
  28. <u--input
  29. v-model="model1.userInfo.sex"
  30. disabled
  31. disabledColor="#ffffff"
  32. placeholder="请选择性别"
  33. border="none"
  34. ></u--input>
  35. <u-icon
  36. slot="right"
  37. name="arrow-right"
  38. ></u-icon>
  39. </u-form-item>
  40. </u--form>
  41. <u-action-sheet
  42. :show="showSex"
  43. :actions="actions"
  44. title="请选择性别"
  45. description="如果选择保密会报错"
  46. @close="showSex = false"
  47. @select="sexSelect"
  48. >
  49. </u-action-sheet>
  50. </view>
  51. <view class="actions safe-area-bottom">
  52. <u-button @click="onSubmit">确认提交</u-button>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. export default {
  58. data(){
  59. return {
  60. showSex: false,
  61. model1: {
  62. userInfo: {
  63. name: 'uView UI',
  64. sex: '',
  65. },
  66. },
  67. rules: {
  68. 'userInfo.name': {
  69. type: 'string',
  70. required: true,
  71. message: '请填写姓名',
  72. trigger: ['blur', 'change']
  73. },
  74. 'userInfo.sex': {
  75. type: 'string',
  76. max: 1,
  77. required: true,
  78. message: '请选择男或女',
  79. trigger: ['blur', 'change']
  80. },
  81. },
  82. radio: '',
  83. switchVal: false
  84. }
  85. },
  86. onReady() {
  87. //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  88. this.$refs.uForm.setRules(this.rules)
  89. },
  90. methods: {
  91. sexSelect(e) {
  92. this.model1.userInfo.sex = e.name
  93. this.$refs.uForm.validateField('userInfo.sex')
  94. },
  95. onSubmit() {
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. .info {
  102. position: relative;
  103. height: 100vh;
  104. .main {
  105. height: calc(100vh - 88px);
  106. padding: 40rpx;
  107. overflow: scroll;
  108. }
  109. .actions {
  110. position: absolute;
  111. bottom: 0;
  112. left: 0;
  113. width: 100%;
  114. }
  115. }
  116. </style>