白瑕 2022-04-16 13:48 采纳率: 80%
浏览 743
已结题

el-upload无法获取fileList

在onchange事件时输出fileList, 结果为undefined.
问题相关代码,请勿粘贴截图
<template>
  <el-upload
    action="https://jsonplaceholder.typicode.com/posts/"
    :show-file-list="true"
    :on-change="onchange()"
    :before-upload="onchange()"
    :auto-upload="false"
    ref="upload"
    :file-list="data.fileList"
  >
    <template v-slot:trigger>
      <el-button type="primary">选择文件</el-button>
    </template>
    <el-button class="ml-3" type="success" @click="submit"> 上传 </el-button>
    <template v-slot:tip>
      <div class="el-upload__tip text-red">
        limit 1 file, new file will cover the old file
      </div>
    </template>
  </el-upload>
</template>
import { ref, reactive } from "vue";
const upload = ref(null);

export default {
  setup() {
    let data = reactive({
      fileList: [],
    });

    const onchange = (file, fileList) => {
      console.log(file);
      console.log(fileList);
    };

    return {
      data,
      onchange,
      upload
    };
  },
};
运行结果及报错内容

img

感谢
  • 写回答

2条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      问题事件

      • 系统已结题 6月16日
      • 已采纳回答 6月8日
      • 创建了问题 4月16日

      悬赏问题

      • ¥20 有ASP .NET MVC做的小说阅读网站吗?
      • ¥20 beeline客户端支持ipv6地址连接hive服务
      • ¥15 香农解码的代码问题,无法输出解码结果
      • ¥15 Python操作注册表
      • ¥45 入门级别的一段VUE前端拍照像后端发送请求的代码,帮排错
      • ¥15 anaconda打开spyder后一直闪退,不知道怎么办
      • ¥15 解决迷宫问题中无法运行的问题
      • ¥15 关于aspnetcore中使用mqttnet库的entire
      • ¥15 关于#python#的问题,请各位专家解答!
      • ¥100 关于远控软件的两个问题