wxmlify
v1.2.0
Un plug-in léger et rapide qui vous aide à afficher le HTML généré par l'éditeur de texte enrichi dans les mini-programmes WeChat.
<rich-text>
, mais sa compatibilité n'est pas garantie pour le moment. Vous aurez peut-être encore besoin d'outils d'analyse tiers.font-size
, font-weight
etc. du document d'origine. // pages/index/index.js
var Wxmlify = require ( '../../wxmlify/wxmlify.js' )
Page ( {
onLoad ( ) {
// 以任何方式获得要解析的Html代码
var html = getHTMLStringSomehow ( )
// new 一个 wxmlify 实例就好了
var wxmlify = new Wxmlify ( html , this , { } )
}
} )
<!-- pages/index/index.wxml -->
< import src =" ../../wxmlify/wxmlify.wxml " />
< template is =" wxmlify " data =" {{nodes: wxmlified}} " > </ template >
new Wxmlify ( html , page [ , options ] )
this
dans toutes les méthodes de pagestring
'wxmlified'
new Wxmlify ( html , this , {
dataKey : 'myRichText'
} )
En conséquence dans wxml :
< template is =" wxmlify " data =" {{nodes: myRichText}} " > </ template >
'all'
signifie conserver tous les stylesfalse
, 0
, null
, signifient la suppression de tous les styles intégrés['fontSize', 'fontWeight', 'background']
'all'
(laisser tous les styles par défaut) boolean
false
function
function() {}
. wxmlified-element {
/* 修改段落块的样式 */
}
. wxmlified-element . h1 {
/* 修改原<h1>标签块的样式,其它块级标签同理 */
}
. wxmlified-image {
/* 修改图片的样式 */
}
. wxmlified-text {
/* 修改文字节点的样式 */
}
. wxmlified-table . table {
/* table 的样式 */
border : 1 rpx solid # acacac ;
}
. wxmlified-table . tr {
/* tr 的样式 */
border-bottom : 1 rpx solid # acacac ;
}
. wxmlified-table . tr : last-child {
border-bottom : 0 ;
}
. wxmlified-table . th , . wxmlified-table . td {
/* th,td 的样式 */
border-right : 1 rpx solid # acacac ;
line-height : 2 ;
}
. wxmlified-table . th : last-child , . wxmlified-table . td : last-child {
border-right : none;
}
. wxmlified-table . th {
font-weight : bold;
}
? Ce petit outil est rendu possible grâce à un analyseur HTML-JSON open source himalaya créé par Chris Andrejewski.