有关在自定义组件中添加 input 标签

发布于 6 年前作者 qianxiuying3390 次浏览最后编辑 6 年前来自 ask

<view class="recipient-form-item">


  <label
    class="{{(value !== '' || focus)  ? 'narrow' : '' }}"
  >
    {{ label }}

  </label>


  <input
    type="text"
    value="{{ value }}"
    name="{{ name }}"
    bindinput="onInput"
    bindfocus="bindFocus"
    bindblur="bindBlur"

  />


</view>

在自定义组件中添加 input 标签无法使用自带 form 方法获取该 input 组件的值

求解

2 回复
mxiong
mxiong1 楼6 年前

想要form能获取自定义组件里的表单元素的值,可以使用 https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/behaviors.html 里的内置behaviors