button 中的 open-type开放了很多功能,请问能用事件bindtap打开吗?
发布于 4 年前 作者 jiehuang 11585 次浏览 来自 官方Issues

写好的一个图片样式,不想用按钮button打开,有办法实现吗?

想点击某个view,打开button中的开放能力open-type。

3 回复

除了最后一个可以使用 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;
}

这种情况我一般是用<button plain=“true” style=“background-image:url({{imageSrc}})”/>,再加点样式,类似这样:

{

  width: 48rpx;

  height: 48rpx;

  background-size: 48rpx 48rpx;

  background-position: 0rpx 0rpx;

  background-repeat: no-repeat;

}

回到顶部