您的位置:首页 > 移动开发 > 微信开发

微信小程序自定义组件

2018-05-21 19:02 316 查看

自定义组件:对一些内容进行组件用起来比较方便。


一、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"
}
}


阅读更多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: