uniapp develops WeChat applet to crop avatar

uniapp plug-in market: https://ext.dcloud.net.cn/plugin?id=404

It has been tested that the WeChat applet and app can be used normally

//template部分
    <avatar 
        selWidth="200px" selHeight="400upx" @upload="myUpload" :avatarSrc="url"
        avatarStyle="width: 200upx; height: 200upx; border-radius: 100%;">
    </avatar>

//script部分
    import avatar from "../../components/yq-avatar/yq-avatar.vue";
    export default {
        data() {
            return {
                screenshot: "../../static/logo.png"
            }
        },
        methods: {
            myUpload(rsp) {
                this.screenshot = rsp.path; //更新头像方式一
                //rsp.avatar.imgSrc = rsp.path; //更新头像方式二
            }
        },
        components: {
            avatar
        }
    }

Just upload the picture to the server

Renderings:

Guess you like

Origin blog.csdn.net/maowencai/article/details/128934754