html + js 上傳 圖片

vue 環境

<a href="javascript:;" class="upload right">
    <input @change="fileImage" type="file" accept="image/jpeg,image/x-png,image/gif" id="" value=""/>
</a>
  fileImage(e) {
      var that=this;
      var file = e.target.files[0];
      var imgSize=file.size/1024;
      if(imgSize>1024){
        alert('請上傳大小不要超過1M的圖片')
      }else{
        // 調用接口,獲取你的圖片地址
      }
   }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章