<template>
  <
label for="file" class=" btn btn-default" style="border:1px solid red">多文件上传</label>   <input type="file" style="display:none;" id="file" multiple @change="file()" name="multipartFiles">   <table style="width:500px;margin:0 auto;" id="wenjian">     <tr style="" id="col">       <th class="name">文件名</th>       <th class="size">大小</th>       <th class="zhuangtai">状态</th>       <th>操作</th>     </tr>     <tr :class="isactive?aaa:''" v-for="(dd,index) in wenjian" :key="index" id="tr">       <td>{{dd.name}}</td>       <td>{{(dd.size/1024).toFixed(1)}}kb</td>       <td>等待上传</td>       <td><button @click="del(index)">删除</button></td>     </tr>   </table>
</template>

date(){
  return{
    wenjian:[],
    isactive:true,
    aaa:'aaaclass'
  }
}
methods:{
 file(){
      var that = this;
      for(var ff=0;ff<$("#file")[0].files.length;ff++){
        that.wenjian.push($("#file")[0].files[ff])
      }
      that.isactive = false;
      //console.log($("#file")[0].files)
      //console.log(that.wenjian)      
    },
del(index){
      //console.log(111)
      var that = this;
      //console.log(that.wenjian)
      that.wenjian.splice(index,1)
    },
}

<style>.aaaclass{display:none;}</style>


vue项目 多文件上传并显示在页面上

这是效果图。

相关文章:

  • 2021-11-15
  • 2021-11-05
  • 2021-12-06
  • 2021-12-16
  • 2021-12-05
  • 2021-06-18
  • 2021-11-19
  • 2021-10-19
猜你喜欢
  • 2021-10-06
  • 2021-09-20
  • 2021-12-06
  • 2021-12-12
  • 2021-12-12
  • 2020-06-26
  • 2021-06-26
  • 2021-12-19
相关资源
相似解决方案