• 请不要在回答技术问题时复制粘贴 AI 生成的内容
liKeYunKeji
V2EX  ›  程序员

uni-app 渲染富文本,图片自适应屏幕的问题

  •  
  •   liKeYunKeji · Feb 18, 2019 · 8480 views
    This topic created in 2670 days ago, the information mentioned may be changed or developed.

    index.vue

    <template>
    	<view class="content">
            <view class="ricetext">
            	<rich-text :nodes="item.zhengwen"></rich-text>
            </view>
    	</view>
    </template>
    

    index.css

    .content .ricetext{
    	width: 90%;
    	margin:5px auto 20px;
    	text-align: justify;
    	font-size: 17px;
    }
    
    .content .ricetext img{
    	width: 300px;
    }
    
    

    这样写 css,图片还是没有受到影响,还会以原来的尺寸溢出 90%外面。 接口返回的 json 格式数据如下:

    [{"id":"3115","resname":"\u5f00\u53d1\u6d4b\u8bd5...","resint":"\u4fee\u6539 2019-02-18","resurl":0,"fangwl":"1","cang":"0","liuyannum":"0","dianzan":"0","zhengwen":"<p><img src=\"http:\/\/bpic.588ku.com\/art_origin_min_pic\/18\/11\/30\/b26b5b7eba8ab2ebc0339126bfde4669.jpg\"\/><\/p><p><br\/><\/p><p>\u91cc\u5ba2\u4e91\u6b63\u5728\u5f00\u53d1APP\uff0c\u8fd9\u6761\u4e3a\u6d4b\u8bd5\u6570\u636e\uff0c\u5927\u5bb6\u53ef\u4ee5\u5ffd\u7565\uff01\uff01\uff01<\/p>"}]
    

    我只是想让 img 的大小自适应屏幕大小。

    5 replies    2019-03-03 10:16:04 +08:00
    liKeYunKeji
        1
    liKeYunKeji  
    OP
       Feb 18, 2019
    已经解决了
    xbj126
        2
    xbj126  
       Mar 2, 2019
    怎样解决的呀?我也遇到同样问题了,求教!
    xbj126
        3
    xbj126  
       Mar 2, 2019
    liKeYunKeji
        4
    liKeYunKeji  
    OP
       Mar 2, 2019 via iPhone
    @xbj126 在数据库 img 标签加宽度
    xbj126
        5
    xbj126  
       Mar 3, 2019
    @pytth get !谢谢,看来只能后端处理了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2990 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 14:46 · PVG 22:46 · LAX 07:46 · JFK 10:46
    ♥ Do have faith in what you're doing.