Address.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <view>
  3. <template v-for="(item, index) in addInfoArr" :key="index">
  4. <add-component ref="addComponentRef"></add-component>
  5. </template>
  6. <view>
  7. <!-- <up-button type="primary" text="添加" @click="handleAdd"></up-button> -->
  8. <up-button type="error" text="确定" @click="handlOk"></up-button>
  9. </view>
  10. </view>
  11. </template>
  12. <script setup>
  13. import {
  14. ref,
  15. reactive
  16. } from 'vue';
  17. import {
  18. useraDdressData
  19. } from "@/api/userSettings.js"
  20. import pickerAddress from '@/components/pickerAddress/pickerAddress.vue' // 地区选择器组件
  21. import addComponent from '@/pages_mine/components/setupUser/Add.vue'
  22. const addComponentRef = ref(null)
  23. const addInfoArr = ref([
  24. {}
  25. ])
  26. function handleAdd() {
  27. if(addInfoArr.value.length < 4 ) addInfoArr.value.push({})
  28. }
  29. const handlOk = async () => {
  30. const params = []
  31. addInfoArr.value.forEach((item, index) => {
  32. params.push(addComponentRef.value[index].modelForm)
  33. })
  34. params.forEach(async (obj) => {
  35. const res = await useraDdressData(obj)
  36. console.log(res,'ok')
  37. })
  38. console.log(addComponentRef.value, '>>>>>>vaddComponentRef')
  39. console.log(params, '>>>>>>params');
  40. }
  41. </script>
  42. <style scoped lang="scss">
  43. .address-inp {
  44. color: #929292;
  45. }
  46. </style>