<form report-submit=‘true’ bindsubmit=‘butSubmit’>
<slot name=“form”>slot>
<button class=‘bnt’ form-type=‘submit’ bindgetuserinfo=“getUserInfo” lang=“zh_CN” bindgetphonenumber=“getPhoneNumber” open-type="{{openType}}">
<slot name=“but”>slot>
button>
form>
向slot 中插入input。form获取不到它的值?怎么解决?
部分代码:
<authorizeView bind:onBut=“onNext” >
<view slot=“form” class=“authorizeView”>
<image mode=‘aspectFill’ class=‘team_logo’></image>
<view class=‘team_logo_tip’>上传队徽</view>
<view class=‘item’>
<view class=‘name’>球队名称</view>
<input bindinput=“onGroupName” name=“group_name” maxlength="{{15}}" placeholder=‘取个好听的名字吧(15个字以内)’ placeholder-class=‘inputPlaceholder’></input>
</view>
这里面的input
form组件不能获取到slot里的表单元素的值,这是设计如此
建议form不要封装成自定义组件,input可封装成自定义组件,参考 https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/behaviors.html 内置behavior
<authorizeView bind:onBut=“onNext” >
<view slot=“form” class=“authorizeView”>
<image mode=‘aspectFill’ class=‘team_logo’></image>
<view class=‘team_logo_tip’>上传队徽</view>
<view class=‘item’>
<view class=‘name’>球队名称</view>
<input bindinput=“onGroupName” name=“group_name” maxlength="{{15}}" placeholder=‘取个好听的名字吧(15个字以内)’ placeholder-class=‘inputPlaceholder’></input>
</view>
这里面的input ,通过slot插入到自定义组件!