contact.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <template>
  2. <view class="pa-3">
  3. <uni-forms ref="baseForm" :modelValue="baseFormData">
  4. <uni-forms-item label="姓名" required label-width="100">
  5. <uni-easyinput v-model="baseFormData.name" placeholder="请输入姓名" />
  6. </uni-forms-item>
  7. <uni-forms-item label="手机号" required label-width="100">
  8. <uni-easyinput v-model="baseFormData.phone" placeholder="请输入联系手机号" />
  9. </uni-forms-item>
  10. <uni-forms-item label="企业名称" required label-width="100">
  11. <uni-easyinput v-model="baseFormData.enterpriseName" placeholder="请输入企业名称" />
  12. </uni-forms-item>
  13. </uni-forms>
  14. <button type="primary" @click="submit">提交</button>
  15. </view>
  16. </template>
  17. <script setup>
  18. import { ref } from 'vue'
  19. const baseForm = ref()
  20. const baseFormData = ref({
  21. name: '',
  22. phone: '',
  23. enterpriseName: ''
  24. })
  25. const submit = async () => {
  26. await baseForm.value.validate()
  27. uni.showToast({ title: '保存成功', icon: 'none' })
  28. // baseForm.value.validate().then((res) => {
  29. // console.log('表单数据:', res)
  30. // uni.showToast({ title: '保存成功', icon: 'none' })
  31. // }).catch((err) => {
  32. // // uni.showToast({ title: err?.msg || '保存失败', icon: 'none' })
  33. // })
  34. }
  35. </script>
  36. <style lang="scss" scoped>
  37. .pa-3 {
  38. padding: 30rpx;
  39. }
  40. </style>