zoukankan      html  css  js  c++  java
  • uni-app 图片选择及文件上传

    <template>
        <view>
            <button @click="img" type="primary">button</button>
             <progress :percent="percent" stroke-width="10" />
        </view>
    </template>
    
    <script>
        var _self;
        export default {
            data() {
                return {
                    percent:0
                }
            },
            onLoad(e) {
                _self=this
            },
            methods: {
                img(){
                    //选择照片
                    uni.chooseImage({
                        count:1,
                        sizeType:'compressed',
                        success: (res) => {
                            const imgsFile=res.tempFilePaths
                            //上传
                            const uper=uni.uploadFile({
                                url: 'https://demo.hcoder.net/index.php?c=uperTest',
                                filePath:imgsFile[0],
                                name:'file',
                                // formData:{    },用于做令牌认证
                                success:function(res1){
                                    console.log(res1.data)
                                }
                            })
                            //上传进度更新的方法
                            uper.onProgressUpdate((e)=>{
                                console.log(e)
                                _self.percent=e.progress
                            })
                        }
                    })
                }
            }
        }
    </script>
    
    <style>
        
    </style>
  • 相关阅读:
    C#生成唯一值的方法汇总
    Ajax && json在springmvc中的使用
    spring集成mybatis
    mybatis iBatis
    springjdbc
    拦截器
    系统分层
    Java反射(reflect)
    springmvc
    spring 之 使用注解简化配置
  • 原文地址:https://www.cnblogs.com/lxz-blogs/p/12587713.html
Copyright © 2011-2022 走看看