国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > CMS > 織夢DEDE > 正文

織夢百度小程序微信小程序video標簽不支持視頻封面,autoplay等問題修復方法

2024-07-12 09:08:09
字體:
來源:轉載
供稿:網友

在現有的百度小程序富文本組件bdParse,以及微信小程序富文本組件wxParse,對于video的標簽解析僅僅只是有個video而已,其他的屬性幾乎都過濾掉了,所以就需要我們假設對于屬性(由于H5的video屬性和小程序的video屬性要求不一樣,以小程序為主)

一、百度小程序的bdParse修復方法

(1)打開bdParse/bdParse.swan找到video標簽解析處大致第10行:

<template name="bdParseVideo">   <!--增加video標簽支持,并循環添加-->   <view class="{{item.classStr}} bdParse-{{item.tag}}" style="{{item.styleStr}}">     <video class="{{item.classStr}} bdParse-{{item.tag}}-video" src="{{item.attr.src}}"></video>   </view> </template>

改成:

<template name="bdParseVideo">   <!--增加video標簽支持,并循環添加-->   <view class="{{item.classStr}} bdParse-{{item.tag}}" style="{{item.styleStr}}">     <video class="{{item.classStr}} bdParse-{{item.tag}}-video" poster="{{item.attr.poster}}" autoplay="{{item.attr.autoplay}}" controls="{{item.attr.controls}}" loop="{{item.attr.loop}}" muted="{{item.attr.muted}}" src="{{item.attr.src}}"></video>   </view> </template>

 

(2)針對dedecms用戶以及其它video的poster屬性不顯示全網址的修復辦法

在小程序的內容之前使用正則替換,補全poster地址:

dede版百度小程序demo修復:show.js的113行加入以下代碼:

content.body = content.body.replace(/poster=/"(.*)/"/gi, 'poster=/"'+ app.globalData.host+'$1/"');


二、微信小程序wxParse修復方法

(1)打開wxParse/wxParse.wxml找到video標簽解析處大致第13行:

<template name="wxParseVideo">   <!--增加video標簽支持,并循環添加-->   <view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">     <video class="{{item.classStr}} wxParse-{{item.tag}}-video" src="{{item.attr.src}}"></video>   </view> </template>

改成:

<template name="wxParseVideo">   <!--增加video標簽支持,并循環添加-->   <view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">     <video class="{{item.classStr}} wxParse-{{item.tag}}-video" poster="{{item.attr.poster}}" autoplay="{{item.attr.autoplay}}" controls="{{item.attr.controls}}" loop="{{item.attr.loop}}" muted="{{item.attr.muted}}"  src="{{item.attr.src}}"></video>   </view> </template>

(2)同理需要對文章中的poster不是全網址的視頻封面圖片補全網址

dede版微信小程序demo修復:show.js的105行加入以下代碼:

content.body = content.body.replace(/poster=/"(.*)/"/gi, 'poster=/"' + app.globalData.host + '$1/"');


【注意】

小程序的video和H5的video稍微有點不同

autoplay、controls、loop、muted等屬性需要寫成:autoplay=“{{true}}”,controls=“{{true}}”

這樣就可以實現了h5的video標簽的常用屬性,如圖:

織夢百度小程序微信小程序video標簽不支持視頻封面,autoplay等問題修復方法

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 东方市| 定陶县| 乐陵市| 积石山| 滦平县| 巧家县| 子洲县| 化德县| 江都市| 周宁县| 宾阳县| 淄博市| 岱山县| 二手房| 石嘴山市| 金秀| 宁乡县| 木里| 磐安县| 茶陵县| 长沙市| 栾川县| 周至县| 安岳县| 汝南县| 吉首市| 文水县| 黎川县| 崇文区| 郎溪县| 正镶白旗| 巴南区| 浦县| 灌阳县| 清徐县| 股票| 临清市| 沅陵县| 龙门县| 思茅市| 遂宁市|