Skip to content

mp-html 富文本

复制于 mp-html

代码演示

vue
<script setup>
const html = `
  <h1>这是标题1</h1>
  <h2>这是标题2</h2>
  <h3>这是标题3</h3>
  <p>这是段落1</p>
  <p>这是段落2</p>
`

const tagStyle = {
  p: 'font-weight: 400; font-size: 13px; color: rgba(0,0,0,.6);',
  h1: 'font-weight: 600; font-size: 15px; color: red;',
  h2: 'font-weight: 600; font-size: 14px; color: green;',
  h3: 'font-weight: 600; font-size: 13px; color: rgba(0,0,0,1);',
}
</script>

<template>
  <mp-nav-bar title="mp-html" />

  <view class="content">
    <mp-html :content="html" :tag-style="tagStyle" />
  </view>
</template>

<style scoped>
.content {
  padding: 15rpx;
}
</style>

API

Props

Prop nameDescriptionTypeValuesDefault
containerStylestring-''
contentstring-''
copyLinkboolean|string-true
domainstring-
errorImgstring-''
lazyLoadboolean|string-false
loadingImgstring-''
pauseVideoboolean|string-true
previewImgboolean|string-true
scrollTableboolean|string-
selectableboolean|string-
setTitleboolean|string-true
showImgMenuboolean|string-true
tagStyleobject-
useAnchorboolean|number-

Events

Event namePropertiesDescription
load
ready
imgtap
linktap
play
error
tap
click

Slots

NameDescriptionBindings
default

源码

组件示例