I use the VUE framework

Reference wechat JS

<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
Copy the code
/* Call wechat preview image method */
		funcReadImgInfo() {
			let imgs = [];
			// Get all the img tag objects in the text
			let imgObj = document.getElementsByClassName('image_box');
			let l = imgObj.length;
			// Iterate to get the URL
			for (let i = 0; i < l; i++) {
				imgs.push(imgObj[i].src);
				// Call wechat built-in picture browsing
				imgObj[i].onclick = function () {
					let nowImgurl = this.src;
					// Get the current clicked image URL. Remember that the URL must be HTTP
					WeixinJSBridge.invoke("imagePreview", {
						"urls": imgs,
						"current": nowImgurl
					})
				}
			}
		},
Copy the code

 

Call after loading native JS page:

window. &western nl &western AD =function(){
    var _this = this;
    _this.funcReadImgInfo();
}
Copy the code

Call after vue page loading:

// After the asynchronous data request completes
setTimeout(function(){
    var _this = this;
    _this.funcReadImgInfo();
},500)
Copy the code

That will do

If you have any difficulties, please leave a message