0.1.1 • Published 6 years ago

mitoo-weapp v0.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

介绍

Mitoo-weapp是一款基于小程序的ui组件库,旨在解决ios和android上展示的差异化,提升开发者的开发效率,把更多的精力放到业务上。

开始使用

在开始使用Mitoo-weapp 之前,你需要先阅读 微信小程序自定义组件的相关文档

下载项目到工程

npm install --save mitoo-weapp

预览

  • 在 Mitoo-weapp 根目录下运行
# 下载工程到本地
git clone https://github.com/Mitoo-FE/Mitoo-weapp.git
  • 打开微信web开发者工具,'本地小程序项目 - 添加项目',把 mitoo-weapp/demo 目录添加进去就可以预览示例demo了。

具体组件

ActtionSheet

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-action-sheet": "/components/ActionSheet/index",
	}
}

Step 2

在wxml文件里添加组件代码

<mit-action-sheet visible="{{ visible }}" mask-closable="{{ false }}"></mit-action-sheet>

API

参数说明类型默认值必须
title标题Stringfalse
visible用来显示action sheetBooleanfalsefalse
mask-closable点击遮罩层是否可以关闭组件Booleanfalsefalse
options按钮标题列表Objectture
cancelButtonText取消按钮的文案String取消false
tapItem点击按钮的时间Functionfalse

Alert

提示框组件

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-alert": "/components/Alert/index",
	}
}

Step 2

在wxml文件里添加组件代码

<mit-alert>
    ...
</mit-alert>

API

参数说明类型默认值必须可选参数
text内容String
warning警告样式提示框Booleanfalsefalsetrue, false
error错误样式提示框Booleanfalsefalsetrue, false
success成功样式提示框Booleanfalsefalsetrue, false
closeable可关闭提示框Booleanfalsefalsetrue, false

Avatar

头像组件

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-avatar": "/components/Avatar/index",
	}
}

Step 2

在wxml文件里添加组件代码

<mit-avtar>
    ...
</mit-avatar>
参数说明类型默认值必须可选参数
src头像图片地址Stringfalse
size头像大小String'default'true'large', 'small', 'default', number
noCircle是否圆头像Booleanfalsefalse
border是否有边框Booleanfalsefalse

Badge

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-badge": "/components/Badge/index",
	}
}

Step 2

在wxml文件里添加组件代码

<mit-badge>
    ...
</mit-badge>

API

参数说明类型默认值必须可选参数
number徽章上的数字Number
flag是否加到其他组件上面Booleanfalsefalsetrue, false
color自定义徽章颜色String

Button

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-button": "/components/Button/index",
	}
}

Step 2

在wxml文件里添加组件代码

<mit-button>
    ...
</mit-button>

API

参数说明类型默认值必须可选参数生效时机
size大小Stringdefaultfalse'small', 'large', 'default'
circle是否圆按钮Booleandefaultfalsetrue, false
text按钮文字Stringfalse
type按钮类型Stringfalse'primary''primary', 'info', 'default', 'error', 'brand', 'brand-yellow', 'brand-red', 'brand-green', 'brand-blue', 'brand-dark-blue'
disabled是否禁用Booleanfalsefalsetrue, false
full是否通栏Booleanfalsefalsetrue, false
bottom是否为底部通栏按钮Booleanfalsefalsetrue, false
openType微信开放能力String
sessionFrom会话来源StringopenType="contact"
sendMessageTitle会话内消息卡片标题StringopenType="contact"
sendMessagePath会话内消息卡片点击跳转小程序路径StringopenType="contact"
sendMessageImg会话内消息卡片图片StringopenType="contact"
showMessageCard显示会话内消息卡片StringopenType="contact"
appParameter打开 APP 时,向 APP 传递的参数StringopenType="launchApp"
bindcontact客服消息回调FunctionopenType="contact"
bindgetphonenumber获取用户手机号回调FunctionopenType="getPhoneNumber"
binderror当使用开放能力时,发生错误的回调FunctionopenType="launchApp"
bindopensetting在打开授权设置页后回调FunctionopenType="openSetting"

Card

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-card": "/components/Card/index",
	}
}

Step 2

在wxml文件里添加组件代码

<mit-card>
    ...
</mit-card>

API

参数说明类型默认值必须
full是否通栏Booleanfalsefalse

Cell

与Cell-Group配合使用

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-cell": "/components/Cell/index",
	}
}

Step 2

在wxml文件里添加组件代码

<mit-cell>
    ...
</mit-cell>
参数说明类型默认值必须可选参数
title标题Stringfalse
label辅助文字Stringfalsetrue
isLink是否是链接Booleanfalsefalse
url链接Stringfalsefalse

注意,在title为空是可以选择使用slot的方式进行渲染,可以在中间添加自己的代码

Cell-Group

与Cell配合使用

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-cell-group": "/components/Cell-Group/index",
	}
}

Step 2

在wxml文件里添加组件代码

<mit-cell-group>
    ...
</mit-cell-group>

Checkbox

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-checkbox": "/components/Checkbox/index",
		"mit-checkbox-group": "/components/Checkbox-Group/index"
	}
}

Step 2

在wxml文件里添加组件代码

<mit-checkbox-group bind:change="onCheckboxChange">
	<mit-checkbox title="西瓜" value="watermelon"></mit-checkbox>
	<mit-checkbox title="香蕉" value="banana"></mit-checkbox>
	<mit-checkbox title="苹果" value="apple"></mit-checkbox>
	<mit-checkbox title="梨" value="pear"></mit-checkbox>
</mit-checkbox-group>

API

Checkbox

参数说明类型默认值必须
title标题Stringtrue
valuecheckbox的value值,当value为空时,取title值Stringfalse
checked默认选中Booleanfalse
disabled不取选Booleanfalse

Checkbox-Group

参数说明类型默认值必须
change点击的时候触发的时间Functionfalse

Checkbox

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-checkbox": "/components/Checkbox/index",
		"mit-checkbox-group": "/components/Checkbox-Group/index"
	}
}

Step 2

在wxml文件里添加组件代码

<mit-checkbox-group bind:change="onCheckboxChange">
	<mit-checkbox title="西瓜" value="watermelon"></mit-checkbox>
	<mit-checkbox title="香蕉" value="banana"></mit-checkbox>
	<mit-checkbox title="苹果" value="apple"></mit-checkbox>
	<mit-checkbox title="梨" value="pear"></mit-checkbox>
</mit-checkbox-group>

API

Checkbox

参数说明类型默认值必须
title标题Stringtrue
valuecheckbox的value值,当value为空时,取title值Stringfalse
checked默认选中Booleanfalse
disabled不取选Booleanfalse

Checkbox-Group

参数说明类型默认值必须
change点击的时候触发的时间Functionfalse

Drawer

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-drawer": "/components/Drawer/index",
	}
}

Step 2

在wxml文件里添加组件代码

<mit-drawer>
    ...
</mit-drawer>

API

参数说明类型默认值必须可选参数
position出现的位置Stringtrue'left','right'
visible可见性Booleanfalsetruetrue, false

Grid

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-grid": "/components/Grid/index",
		"mit-grid-item": "/components/Grid-Item/index"
	}
}

Step 2

在wxml文件里添加组件代码

<mit-grid columnNum="3">
	<mit-grid-item>
		<view slot="icon"><mit-icon type="category" size="40" /></view>
		<view slot="title">我是一个分类</view>
	</mit-grid-item>
	<mit-grid-item>
		<view slot="icon"><mit-icon type="category" size="40" /></view>
		<view slot="title">我是一个分类</view>
	</mit-grid-item>
	<mit-grid-item>
		<view slot="icon"><mit-icon type="category" size="40" /></view>
		<view slot="title">我是一个分类</view>
	</mit-grid-item>
</mit-grid>

API

Grid

参数说明类型默认值必须
columnNum标题Stringtrue

Grid-Item

参数说明类型默认值必须
iconiconslotfalse
titletitleslotfalse

Grid

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-grid": "/components/Grid/index",
		"mit-grid-item": "/components/Grid-Item/index"
	}
}

Step 2

在wxml文件里添加组件代码

<mit-grid columnNum="3">
	<mit-grid-item>
		<view slot="icon"><mit-icon type="category" size="40" /></view>
		<view slot="title">我是一个分类</view>
	</mit-grid-item>
	<mit-grid-item>
		<view slot="icon"><mit-icon type="category" size="40" /></view>
		<view slot="title">我是一个分类</view>
	</mit-grid-item>
	<mit-grid-item>
		<view slot="icon"><mit-icon type="category" size="40" /></view>
		<view slot="title">我是一个分类</view>
	</mit-grid-item>
</mit-grid>

API

Grid

参数说明类型默认值必须
columnNum标题Stringtrue

Grid-Item

参数说明类型默认值必须
iconiconslotfalse
titletitleslotfalse

Icon

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-icon": "/components/Icon/index"
	}
}

Step 2

在wxml文件里添加组件代码

<mit-icon type="category" size="30" color="red" mit-class="fontClass"></mit-icon>

API

Grid

参数说明类型默认值必须
type名字Stringtrue
size字体大小,单位rpxNumberfalse
color字体颜色Stringfalse
mit-class字体样式类Stringfalse
注:如果给了size和color属性,mit-class不会覆盖size和color样式。

Input

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-input": "/components/Input/index",
	}
}

Step 2

在wxml文件里添加组件代码

<mit-input>
    ...
</mit-input>

API

参数说明类型默认值必须可选参数
placeholder输入框内描述文字Stringtrue
label左边文字Stringfalse
number是否使用数字键盘输入Booleanfalsefalse
disabled禁用Booleanfalsefalse
value默认文字Stringfalse
radius是否圆角Booleanfalsefalse
borderColor自选边框颜色Booleanfalsefalse
lengthLimit长度限制Numberfalsefalse
confirmType键盘右下角完成文字String"done"
focus自动获取焦点Booleanfalsefalse
type文本框类型Stringfalsefalse'text', 'password', 'idcard', 'digit'
placeholderClassplaceholder类Stringfalsefalse
placeholderStyleplaceholder样式Stringfalsefalse

事件

事件名称说明
change绑定变化时触发
focus获取焦点时触发
blur失焦时触发

Modal

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-modal": "/components/Modal/index",
	}
}

Step 2

在wxml文件里添加组件代码

<mit-modal>
    ...
</mit-modal>

API

参数说明类型默认值必须可选参数
visible是否可见Booleantruetrue,false
title标题Stringfalse
vertical纵向按钮Booleanfalsefalse
footer底部按钮Arrayfalsefalse
footer数组参数
color底部按钮颜色Stringfalsefalse
text底部按钮文字Stringfalsefalse
event按钮上具体事件Functionfalsefalse
closeable该按钮可否关闭对话框Booleanfalsefalse

NoticeBar

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-notice-bar": "/components/NoticeBar/index",
	}
}

Step 2

在wxml文件里添加组件代码

<mit-notice-bar>
    ...
</mit-notice-bar>

API

参数说明类型默认值必须可选参数
text通知文字Stringfalse
closeable是否可关闭Booleanfalsefalse
transform是否可开启跑马灯Booleanfalsefalse

Panel

与其他组件配合使用

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-panel": "/components/Panel/index",
	}
}

Step 2

在wxml文件里添加组件代码

<mit-panel>
    ...
</mit-panel>

API

参数说明类型默认值必须可选参数
title标题Booleanfalsetrue
withoutBorder不带边框Booleanfalsefalsetrue, false

Panel

与其他组件配合使用

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-panel": "/components/Panel/index",
	}
}

Step 2

在wxml文件里添加组件代码

<mit-panel>
    ...
</mit-panel>

API

参数说明类型默认值必须可选参数
title标题Booleanfalsetrue
withoutBorder不带边框Booleanfalsefalsetrue, false

Radio

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-radio": "/components/Radio/index",
		"mit-radio-group": "/components/Radio-Group/index"
	}
}

Step 2

在wxml文件里添加组件代码

<mit-radio-group bind:change="onradioChange">
	<mit-radio title="西瓜" value="watermelon"></mit-radio>
	<mit-radio title="香蕉" value="banana"></mit-radio>
	<mit-radio title="苹果" value="apple"></mit-radio>
	<mit-radio title="梨" value="pear"></mit-radio>
</mit-radio-group>

API

radio

参数说明类型默认值必须
title标题Stringtrue
valueradio的value值,当value为空时,取title值Stringfalse
checked默认选中Booleanfalse
disabled不取选Booleanfalse

radio-Group

参数说明类型默认值必须
change点击的时候触发的时间Functionfalse

Radio

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-radio": "/components/Radio/index",
		"mit-radio-group": "/components/Radio-Group/index"
	}
}

Step 2

在wxml文件里添加组件代码

<mit-radio-group bind:change="onradioChange">
	<mit-radio title="西瓜" value="watermelon"></mit-radio>
	<mit-radio title="香蕉" value="banana"></mit-radio>
	<mit-radio title="苹果" value="apple"></mit-radio>
	<mit-radio title="梨" value="pear"></mit-radio>
</mit-radio-group>

API

radio

参数说明类型默认值必须
title标题Stringtrue
valueradio的value值,当value为空时,取title值Stringfalse
checked默认选中Booleanfalse
disabled不取选Booleanfalse

radio-Group

参数说明类型默认值必须
change点击的时候触发的时间Functionfalse

Row, Col

使用指南

我们采用了24格栅格系统,将一个设计区域分割成24份,使用时需要row和col一起使用,具体示例如下。

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-row": "/components/Row/index",
		"mit-col": "/components/Col/index"
	}
}

Step 2

在wxml文件里添加组件代码

<mit-row mit-class="row">
	<mit-col mit-class="col" span="24">
		<view class="grid-content">span 24</view>
	</mit-col>
</mit-row>

API

row

参数说明类型默认值必须
gutter栅格间隔,单位rpxfalse
mit-class额外样式Stringfalse

col

参数说明类型默认值必须
span栅格占位格数,Numbertrue
offset栅格左侧的间隔格数Numberfalse

Switch

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-switch": "/components/Switch/index",
	}
}

Step 2

在wxml文件里添加组件代码

<mit-switch name="sw1"/>

API

参数说明类型默认值必须可选参数
namenameStringtrue
large大小Booleanfalse
color自定义颜色Stringfalsefalse
disabled禁用Booleanfalsefalse
事件名称说明
change绑定变化时触发

Tabs

与Tabs-Cell配合使用

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-tabs": "/components/Tabs/index",
	}
}

Step 2

在wxml文件里添加组件代码

<mit-tabs>
    ...
</mit-tabs>

API

参数说明类型默认值必须可选参数
brandColor自定义品牌色Stringfalse
scroll是否可滑动Booleanfalsefalse

Tabs-Cell

与Tabs配合使用

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-tabs-cell": "/components/Tabs-Cell/index"
	}
}

Step 2

在wxml文件里添加组件代码

<mit-tabs-cell>
    ...
</mit-tabs-cell>

API

参数说明类型默认值必须可选参数
active是否选中Booleanfalsefalse

Panel

与其他组件配合使用

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-panel": "/components/Panel/index",
	}
}

Step 2

在wxml文件里添加组件代码

<mit-panel>
    ...
</mit-panel>

API

参数说明类型默认值必须可选参数
title标题Booleanfalsetrue
withoutBorder不带边框Booleanfalsefalsetrue, false

Toast

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-toast": "/components/Toast/index",
	}
}

Step 2

在wxml文件里添加组件代码

<mit-button size="large" type="default" bindtap="showBase">基础样式</mit-button>
<mit-button size="large" type="default" bindtap="showSuccess">成功!</mit-button>
<mit-button size="large" type="default" bindtap="showFail">失败!</mit-button>
<mit-button size="large" type="default" bindtap="showNetwork">网络连接失败!</mit-button>
<mit-button size="large" type="default" bindtap="showLoading">加载中</mit-button>
<mit-toast id="toast"></mit-toast>

Step 3

在js文件中使用

const { Toast } = require('../../components/Mixins/Toast');

# 详细代码使用请查看demo
Page({
	showBase() {
		Toast({
			content: '普通的tosat提示!'
		})
	}
})

API

Toast

参数说明类型默认值必须
contenttoast显示内容Stringtrue
typetoast类型 可选值为 success / fail / network / loadingStringfalse

toptips

使用指南

Step 1

在页面对应的json文件中引入组件

{
	"usingComponents": {
		"mit-toptips": "/components/Toptips/index"
	}
}

Step 2

在wxml文件里添加组件代码

<mit-button size="large" type="default" bindtap="showToptips">通用样式</mit-button>
<mit-button size="large" type="default" bindtap="showSuccess">success</mit-button>
<mit-button size="large" type="default" bindtap="showWarn">warn</mit-button>
<mit-button size="large" type="default" bindtap="showError">error</mit-button>
<mit-button size="large" type="default" bindtap="showTimes">自定义事件时间</mit-button>
<mit-toptips id="toptips"></mit-toptips>

Step 3

在js文件中使用

const { Toptips } = require('../../components/Mixins/Toptips');

# 详细代码使用请查看demo
Page({
	showBase() {
		Toptips({
			content: '这是一个通用样式'
		})
	}
})

API

toptips

参数说明类型默认值必须
contenttoptips显示内容Stringtrue
typetoptips类型 可选值为 success / warn / errorStringfalse
duration延迟时间,单位秒Number1.5(秒)false