Advertisement

Vue.js框架下的图片上传功能模块 vue 原生js 上传图片文件

阅读量:

相关内容较为基础,因此暂不单独编写示例代码进行展示,如需了解可参考现有内容。

关键代码:

复制代码
 <input type="file" accept="image" @change="uploadPhoto" ref="uploadImg" id="fileupload1" />

    
  
    
 <Button type="primary" size="large" @click="handleAddBanner()">上传</Button>
    
    
    
    
复制代码
 data() {

    
     return {
    
             formItem:{
    
                 images:''
    
             }
    
     }
    
 }
    
    
    
    
复制代码
  methods: {

    
     uploadPhoto(e){
    
       this.formItem.images = e.target.files[0]
    
     },
    
     handleAddBanner(){
    
         if(loading){
    

全部评论 (0)

还没有任何评论哟~