ミニプログラム:ミニプログラムによってレンダリングされるリッチテキストコンテンツは、ファイルのダウンロードと別のミニプログラムへのジャンプをサポートします

要求する

バックグラウンドでリッチテキストを編集して小さな端末に表示するには、リッチテキストへのリンクを追加してファイルをダウンロードするか、別の小さなプログラムにジャンプする必要があります。

ステップ

npm i mp-html --save

例としてwepyの紹介を取り上げます

<mp-html
  content="{
    
    {content}}"
  :copy-link="false"
  @linktap="linktap"
/>

// 这里只做了跳转链接和跳转小程序,下载文档之类的也是可以的
linktap(e) {
    
    
  if (e.$wx.detail['data-appid']) {
    
    
    wx.navigateToMiniProgram({
    
    
      appId: e.$wx.detail['data-appid'],
      envVersion: __BASE_URL__ === 'https://mcptest.cmvalue.com' ? 'trial' : 'release',
      fail: function (err) {
    
    
        console.log(err)
      }
    })
    return false
  }
  if (e.$wx.detail.href) {
    
    
    wx.navigateTo({
    
    
      url: `/pages/web-view/web-view?url=${
      
      encodeURIComponent(e.$wx.detail.href)}`
    })
  }
}

<config>
{
    
    
  "navigationBarBackgroundColor": "#fff",
  "usingComponents": {
    
    
    "mp-html": "module:mp-html/dist/mp-weixin"
  }
}
</config>

おすすめ

転載: blog.csdn.net/weixin_43972437/article/details/113477439