zhangxiao
2024-08-06 e751c02c93e2f2eb59a479788c174672a41d5918
src/components/upload/index.vue
@@ -10,17 +10,57 @@
</template>
<script setup>
  import { ref } from 'vue';
  import { computed, ref, watch, watchEffect } from 'vue';
  const props = defineProps({
    limit: {
      type: Number,
      default: 1,
    },
    action: String, // 上传的服务器地址
    url: String, //回显的文件地址
  });
  const emit = defineEmits(['update:fileList', 'success']);
  const fileList = ref([]);
  // const urls = computed(() => {
  //   debugger;
  //   console.log(props.url, 999999);
  //   // if (props.urlS) {
  //   //   console.log(props.urlS, 999999);
  //   //   return props.urlS.split(',');
  //   // }
  //   // return props.urlS ? [props.urlS] : [];
  // });
  // watchEffect(() => {
  //   fileList.value = urls.value.map((item) => ({
  //     uid: item,
  //     name: item,
  //     status: 'done',
  //     url: item,
  //   }));
  // });
  watch(
    () => props.url,
    (newVal) => {
      debugger;
      console.log(newVal, 8888);
      // if (newVal) {
      //   fileList.value = newVal.split(',').map((item) => ({
      //     uid: item,
      //     name: item,
      //     status: 'done',
      //     url: item,
      //   }));
      // }
    },
    {
      deep: true, // 开启深度监听
    }
  );
  // console.log(urls.value, 8988);
  const handleChange = (fileList) => {
    emit('update:fileList', fileList);