`; var em = new Vue({ el: "#app", data: function () { return { // 直接保留富文本 HTML,v-html 渲染出图片、表格、排版,还原原网页 postContent: content }; }, mounted() { // 图片默认限制在容器宽度内,避免溢出 this.$nextTick(() => { var _width = $('#app').width(); $('#app img').css('max-width', _width + 'px'); }); } }); //更新监听改变image 宽度 var previousWidth = $(window).width(); $(window).on('resize', function() { var currentWidth = $(this).width(); if (currentWidth < previousWidth) { // 页面缩小时的处理逻辑 页面正在缩小 更新前一个宽度 previousWidth = currentWidth; } else { // 更新前一个宽度 previousWidth = currentWidth; } var _width = $('#app p').width(); $('#app img').css('max-width', _width); //更改父级总高度 window.parent.parentFunction($('#app').height() + 30); });