zoukankan      html  css  js  c++  java
  • 微信小程序 解析html格式内容

    需要引入html-view文件

    1/js 代码

    const HtmlParser=require('../../utils/html-view/index')
    
     data: {
             coupon_text:"",
    }
    
    
    
    let mobiledesc='<div><img src="../../1.png"></div>'
              if(mobiledesc){
                    let coupon_text=new HtmlParser(mobiledesc).nodes;
                    this.setData({
                        coupon_text
                    })
                }else{
                    this.setData({
                        coupon_text:''
                    })
                }

    2/  wxml代码

         <view wx:if="{{coupon_text}}" class="{{iPhoneXStyle?'wap-chooseticket-footer-diff-iponex':'wap-chooseticket-footer-diff'}}">
          <import src="../../utils/html-view/index.wxml" />
          <template is="html-view" data="{{data: coupon_text}}" />
        </view>

    3/wxss

     
    .wap-chooseticket-footer-diff {
         100%;
        overflow-x: scroll;
      }
      
      .wap-chooseticket-footer-diff-iponex {
         100%;
        overflow-x: scroll;
      }
      
      .wap-chooseticket-footer-diff view {
         100% !important;
      }
      
      .wap-chooseticket-footer-diff-iponex view {
         100% !important;
      }
      
      .wap-chooseticket-footer-diff .html-view image {
         100% !important;
        display: block;
      }
      
      .wap-chooseticket-footer-diff-iponex .html-view image {
         100% !important;
        display: block;
      }

    4/最后一步,需要在项目中放入html-view整个文件夹,文件夹的可以在github上面下载(可以在github自行搜索html-view)

  • 相关阅读:
    hdu 1595(最短路变形好题)
    hdu 5253(最小生成树)
    hdu 2363(枚举+最短路好题)
    hdu 3440(差分约束好题)
    poj 3169&hdu3592(差分约束)
    hdu 3339(最短路+01背包)
    hdu 2145(迪杰斯特拉)
    CodeForces 581D Three Logos
    CodeForces 510E Fox And Dinner
    CodeForces 484D Kindergarten
  • 原文地址:https://www.cnblogs.com/shuihanxiao/p/11598605.html
Copyright © 2011-2022 走看看