寫于2022年4月5日
需求:做分享/客服消息等功能時(shí),被點(diǎn)擊的UI是張自定義的圖片。
已知:微信官方對(duì)于功能的實(shí)現(xiàn)是采用 button標(biāo)簽 + open-type屬性來完成的。
問題:自定義的ui樣式,會(huì)被小程序的button樣式干擾。
方案:給 button 標(biāo)簽添加一個(gè)樣式,display: contents; 這樣會(huì)保留button的點(diǎn)擊功能,又不會(huì)展示button的樣式。
實(shí)例:
<!-- 客服消息 -->
<button style="display: contents;" open-type="contact">
<image src="/img/service.png"></image>
</button>