<rich-text type="text" :nodes="info.content" image-menu-prevent="true"></rich-text>
//设置图片宽度
const nodes = res.data.content
nodes.map((node, nodeIndex) => {
node.children.map((childNode, childIndex) => {
if(childNode.name === 'img') {
nodes[nodeIndex].children[childIndex].attrs.style = 'width: 100%;height: auto;'
}
})
})
this.nodes = nodes
rich-text 图片大小设置
最新推荐文章于 2025-11-13 11:35:11 发布
这段代码主要用于处理博客内容中的图片,通过遍历`nodes`数组,查找并设置每个图片节点的样式,确保图片宽度为100%,从而适应显示需求。
8094

被折叠的 条评论
为什么被折叠?



