v-html 时对html内容里的img宽度做限制,图片的onload需要一个个生成new Image() 吗
mounted: function () { this.$nextTick(function () { var Img = new Image(); var imgs = $("#infoContent p img"); imgs.each(function (i, v) { Img.src = v.src; Img.onload = function() { if ($(v).width() > 630) { $(v).css('width', '100%'); } } }) }) }
mounted: function () { this.$nextTick(function () { var imgs = $("#infoContent p img"), Img = []; imgs.each(function (i, v) { Img[i] = new Image(); Img[i].src = v.src; Img[i].onload = function() { if ($(v).width() > 630) { $(v).css('width', '100%'); } } }) }) }
人到中年有点甜