I'm trying to get the image src from wxml. All of the image src should be obtained and replaced.
What should replace document.getElementsByTagName in Wechat Mini?
js: var that = this;
var query = wx.createSelectorQuery();
query.select('.classname').boundingClientRect(function (params) {
cosnole.log(params)
})
As for your original question, perhaps you could use a "custom property" (data-xxx) to get your src
<image src="{{src}}" data-src="{{src}}" bindtap="ontap" />
js:
Page({
data: {
src:'1.jpg'
},
ontap:function(e) {
const {src} = e.currentTarget.dataset;
console.log(src);
}
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.