自定义组件:对一些内容进行组件用起来比较方便。
一、weui-input.wxml
<view class="weui-cell weui-cell_input">
<view class="weui-cell__hd">
<view class="weui-label">{{label}}</view>
</view>
<view class="weui-cell__bd">
<input class="weui-input" name="{{inputName}}" type='{{type}}' placeholder="{{placeholder}}"/>
</view>
<view class="weui-cell__ft">
<icon type='{{icon}}' size='23' color='#e64340'></icon>
</view>
</view>
<solt></solt>
二、weui-input.json
{
"component":true,
"usingComponents":{}
}
三、weui-input.js
Component({
properties: {
label: {
type: 'string',
value: '标签',
},
type: {
type: 'string',
value: 'string',
},
inputName: {
type: 'string',
value: 'name',
},
placeholder: {
type: 'string',
value: '请输入',
},
icon: {
type: 'string',
value: 'clear',
},
formtype:{
type:'string',
value:'submit',
},
bindsubmit:{
type:'string',
value:'formSubmit',
},
},
})
调用组件在调用的项目中的json文件中写上
{
"usingComponents":{
"weui-input":"../component/weui-input"
}
}