wxml: <mp-cell prop=""> <mp-uploader binddelete="binddelete" data-field="accountBook" bindfail="uploadError" bindsuccess="uploadSuccess" select="{{selectFile}}" upload="{{uplaodFile}}" max-count="3" title="户口本" tips="首页,家长页,孩子页"></mp-uploader> </mp-cell>
【已解决】关于data-xx不使用e.currentTarget.dataset因该如何获取?wxml: js: data: { rules, form: { name: '' as string, idCard: ''as string , accountBook: '' as string, } }, uploadSuccess(e: any) { const { field } = e.currentTarget.dataset this.setData({ [`form.${field}`]: e.detail.urls }) }, //在setdata中通过使用[`form.${field}`]: e.detail.urls可以将值写入, 写入是实现了,现在请教下因该如何能读取到通过data-field动态绑定的值呢? 问题已解决,用这种方法就可以了 const { field } = e.currentTarget.dataset console.log(e.currentTarget.dataset); // console.log(this.data.[`form.${field}`]); console.log(this.data.form, `${field}`);
2022-03-28