node.wxml 5.2 KB

1234567891011121314151617181920212223242526272829303132
  1. <wxs module="handler">
  2. // 行内标签列表
  3. var inlineTags = {
  4. abbr: true,
  5. b: true,
  6. big: true,
  7. code: true,
  8. del: true,
  9. em: true,
  10. i: true,
  11. ins: true,
  12. label: true,
  13. q: true,
  14. small: true,
  15. span: true,
  16. strong: true,
  17. sub: true,
  18. sup: true
  19. }
  20. /**
  21. * @description 是否使用 rich-text 显示剩余内容
  22. */
  23. module.exports = {
  24. use: function (item) {
  25. // 微信和 QQ 的 rich-text inline 布局无效
  26. if (inlineTags[item.name] || (item.attrs.style || '').indexOf('display:inline') != -1)
  27. return false
  28. return !item.c
  29. }
  30. }
  31. </wxs>
  32. <view class="{{['_'+name+' '+attrs.class]}}" style="{{(attrs.style)}}" id="{{attrs.id}}"><block wx:for="{{childs}}" wx:for-item="n" wx:for-index="i" wx:key="i"><block><block wx:if="{{n.name=='img'&&(opts[1]&&!ctrl[i]||ctrl[i]<0)}}"><image class="_img" style="{{(n.attrs.style)}}" src="{{ctrl[i]<0?opts[2]:opts[1]}}" mode="widthFix"></image></block><block wx:if="{{n.name=='img'}}"><image class="{{['_img '+n.attrs.class]}}" style="{{((ctrl[i]==-1?'display:none;':'')+'width:'+(ctrl[i]||1)+'px;height:1px;'+n.attrs.style)}}" id="{{n.attrs.id}}" src="{{n.attrs.src}}" mode="{{n.h?'':'widthFix'}}" lazy-load="{{opts[0]}}" webp="{{n.webp}}" show-menu-by-longpress="{{opts[3]&&!n.attrs.ignore}}" image-menu-prevent="{{!opts[3]||n.attrs.ignore}}" data-i="{{i}}" data-event-opts="{{[['load',[['imgLoad',['$event']]]],['error',[['mediaError',['$event']]]],['tap',[['imgTap',['$event']]]],['longpress',[['imgLongTap',['$event']]]]]}}" bindload="__e" binderror="__e" catchtap="__e" bindlongpress="__e"></image></block><block wx:else><block wx:if="{{n.type=='text'}}"><text decode="{{true}}">{{n.text}}</text></block><block wx:else><block wx:if="{{n.name=='br'}}"><text>\n</text></block><block wx:else><block wx:if="{{n.name=='a'}}"><view class="{{[(n.attrs.href?'_a ':'')+n.attrs.class]}}" style="{{('display:inline;'+n.attrs.style)}}" id="{{n.attrs.id}}" hover-class="_hover" data-i="{{i}}" data-event-opts="{{[['tap',[['linkTap',['$event']]]]]}}" catchtap="__e"><node style="display:inherit;" vue-id="{{'2c90db8c-1-'+i}}" name="span" childs="{{n.children}}" opts="{{opts}}" bind:__l="__l"></node></view></block><block wx:else><block wx:if="{{n.name=='video'}}"><video class="{{[n.attrs.class]}}" style="{{(n.attrs.style)}}" id="{{n.attrs.id}}" autoplay="{{n.attrs.autoplay}}" controls="{{n.attrs.controls}}" loop="{{n.attrs.loop}}" poster="{{n.attrs.poster}}" src="{{n.src[ctrl[i]||0]}}" data-i="{{i}}" data-event-opts="{{[['play',[['play',['$event']]]],['error',[['mediaError',['$event']]]]]}}" muted="{{n.attrs.muted}}" bindplay="__e" binderror="__e"></video></block><block wx:else><block wx:if="{{n.name=='audio'}}"><audio class="{{[n.attrs.class]}}" style="{{(n.attrs.style)}}" id="{{n.attrs.id}}" author="{{n.attrs.author}}" controls="{{n.attrs.controls}}" loop="{{n.attrs.loop}}" name="{{n.attrs.name}}" poster="{{n.attrs.poster}}" src="{{n.src[ctrl[i]||0]}}" data-i="{{i}}" data-event-opts="{{[['play',[['play',['$event']]]],['error',[['mediaError',['$event']]]]]}}" bindplay="__e" binderror="__e"></audio></block><block wx:else><block wx:if="{{n.name=='table'&&n.c||n.name=='li'}}"><view class="{{['_'+n.name+' '+n.attrs.class]}}" style="{{(n.attrs.style)}}" id="{{n.attrs.id}}"><block wx:if="{{n.name=='li'}}"><node vue-id="{{'2c90db8c-2-'+i}}" childs="{{n.children}}" opts="{{opts}}" bind:__l="__l"></node></block><block wx:else><block wx:for="{{n.children}}" wx:for-item="tbody" wx:for-index="x" wx:key="x"><view class="{{['_'+tbody.name+' '+tbody.attrs.class]}}" style="{{(tbody.attrs.style)}}"><block wx:if="{{tbody.name=='td'||tbody.name=='th'}}"><node vue-id="{{'2c90db8c-3-'+i+'-'+x}}" childs="{{tbody.children}}" opts="{{opts}}" bind:__l="__l"></node></block><block wx:else><block wx:for="{{tbody.children}}" wx:for-item="tr" wx:for-index="y" wx:key="y"><block><block wx:if="{{tr.name=='td'||tr.name=='th'}}"><view class="{{['_'+tr.name+' '+tr.attrs.class]}}" style="{{(tr.attrs.style)}}"><node vue-id="{{'2c90db8c-4-'+i+'-'+x+'-'+y}}" childs="{{tr.children}}" opts="{{opts}}" bind:__l="__l"></node></view></block><block wx:else><view class="{{['_'+tr.name+' '+tr.attrs.class]}}" style="{{(tr.attrs.style)}}"><block wx:for="{{tr.children}}" wx:for-item="td" wx:for-index="z" wx:key="z"><view class="{{['_'+td.name+' '+td.attrs.class]}}" style="{{(td.attrs.style)}}"><node vue-id="{{'2c90db8c-5-'+i+'-'+x+'-'+y+'-'+z}}" childs="{{td.children}}" opts="{{opts}}" bind:__l="__l"></node></view></block></view></block></block></block></block></view></block></block></view></block><block wx:else><block wx:if="{{handler.use(n)}}"><rich-text style="{{(n.f)}}" id="{{n.attrs.id}}" nodes="{{[n]}}"></rich-text></block><block wx:else><block wx:if="{{n.c==2}}"><view class="{{['_'+n.name+' '+n.attrs.class]}}" style="{{(n.f+';'+n.attrs.style)}}" id="{{n.attrs.id}}"><block wx:for="{{n.children}}" wx:for-item="n2" wx:for-index="j" wx:key="j"><node style="{{(n2.f)}}" vue-id="{{'2c90db8c-6-'+i+'-'+j}}" name="{{n2.name}}" attrs="{{n2.attrs}}" childs="{{n2.children}}" opts="{{opts}}" bind:__l="__l"></node></block></view></block><block wx:else><node style="{{(n.f)}}" vue-id="{{'2c90db8c-7-'+i}}" name="{{n.name}}" attrs="{{n.attrs}}" childs="{{n.children}}" opts="{{opts}}" bind:__l="__l"></node></block></block></block></block></block></block></block></block></block></block></block></view>