写好的一个图片样式,不想用按钮button打开,有办法实现吗?
想点击某个view,打开button中的开放能力open-type。
button 中的 open-type开放了很多功能,请问能用事件bindtap打开吗?The open-type in the button has opened many functions, can I open it with the event bindtap?
button 中的 open-type开放了很多功能,请问能用事件bindtap打开吗?写好的一个图片样式,不想用按钮button打开,有办法实现吗?
想点击某个view,打开button中的开放能力open-type。
Write a good picture style, do not want to use button to open, there is a way to achieve it? You want to click a view to open the open type ability in button.
回答:
这种情况我一般是用<button plain="true" style="background-image:url({{imageSrc}})"/>,再加点样式,类似这样:
{
width: 48rpx;
height: 48rpx;
background-size: 48rpx 48rpx;
background-position: 0rpx 0rpx;
background-repeat: no-repeat;
}
除了最后一个可以使用 https://developers.weixin.qq.com/miniprogram/dev/api/open-api/setting/wx.openSetting.html 这个API,其他的没办法通过API直接触发。
建议:
<view class="item"></view>//改写为:<button class="item clearBtn" openType="contact"></button>//button默认样式可以清除.clearBtn { clear: both; margin: 0; padding: 0; box-sizing: inherit; text-decoration: none; border-radius: 0; -webkit-tap-highlight-color: transparent; overflow: hidden; background: none; cursor: pointer; font-weight: normal;}.clearBtn::after { border: 0; box-shadow: 0;}
可以啊