diff --git a/README.md b/README.md
index 00adfecc..377e3248 100644
--- a/README.md
+++ b/README.md
@@ -44,114 +44,58 @@ npm run dev
详细使用文档,请参考 [快速上手](https://www.youzanyun.com/zanui/weapp)
### 组件分类介绍
-根据功能的不同,可以将组件大致的分为4类:
+根据功能的不同,可以将组件大致的分为2类:
-#### 1. 简单组件
+#### 1. 正常引用
-如按钮组件,只要按照wxml结构写就好了
-
-~~~html
+如按钮组件,只需要在页面中引入按钮自定义组件即可
+```json
+{
+ "usingComponents": {
+ "zan-button": "/path/to/zanui-weapp/dist/btn/index"
+ }
+}
+```
+```html
-按钮
-~~~
+按钮
+```

-#### 2. 复杂组件
-如加载更多组件,需要先引入定义好的模版,然后给模版传递数据
+#### 2. API类组件
-~~~html
-
+如 Toast 组件,需要先在页面上引入自定义组件。之后在逻辑运行时,直接调用方法即可展示
+```json
+{
+ "usingComponents": {
+ "zan-toast": "/path/to/zanui-weapp/dist/toast/index"
+ }
+}
+```
+```html
+
+```
-
-
+将对应的 Toast 的函数引入页面,就可以直接调用来展示 Toast 了
-
-
+```js
+// example/toast/index.js
-
-
+const Toast = require('/path/to/zanui-weapp/dist/toast/toast');
-
-
-~~~
-
-
-
-#### 3. 带事件回调的组件
-
-如数量选择组件,需要先引入模版,然后给模版传递数据
-
-~~~html
-
-
-
-
-
-~~~
-
-然后通过`Zan.Stepper`把相关回调注入到页面中
-
-~~~js
-// example/stepper/index.js
-
-var Zan = require('path/to/zanui-weapp/dist/index');
-
-Page(Object.assign({}, Zan.Stepper, {
- data: {
- stepper: {
- stepper: 10,
- min: 1,
- max: 20
- },
- },
-
- handleZanStepperChange(e) {
- // 如果页面有多个Stepper组件,则通过唯一componentId进行索引
- var compoenntId = e.componentId;
- var stepper = e.stepper;
-
- this.setData({
- 'stepper.stepper': stepper
+Page({
+ showToast() {
+ Toast({
+ selector: '#zan-toast-test',
+ message: 'toast内容'
});
}
-}));
-~~~
+});
-
-
-#### 4. API类组件
-
-如Toast组件,需要先引入模版,并在页面上使用。
-
-> 注意`zanToast`这个数据也是通过`Zan.Toast`注入到页面的
-
-~~~html
-
-
-
-
-显示toast
-
-
-~~~
-
-将API注入到页面后,就可以通过`this`来直接调用相应的API了
-
-~~~js
-
-
-var Zan = require('path/to/zanui-weapp/dist/index');
-
-Page(Object.assign({}, Zan.Toast, {
- showToast() {
- this.showZanToast('toast的内容');
- }
-}));
-
-~~~
+```

diff --git a/example/pages/select/index.js b/example/pages/select/index.js
index 13b06e7d..85d7fd1a 100644
--- a/example/pages/select/index.js
+++ b/example/pages/select/index.js
@@ -25,14 +25,12 @@ Page(Object.assign({}, Zan.Select, Zan.TopTips, {
activeColor: '#4b0'
},
- handleZanSelectChange({ componentId, value }) {
+ handleSelectChange({ currentTarget = {}, detail = {} }) {
+ const { value = '' } = detail;
+ const { dataset = {} } = currentTarget;
+ const type = dataset.type;
this.setData({
- [`checked.${componentId}`]: value
+ [`checked.${type}`]: value
});
- },
-
- formSubmit(event) {
- console.log('[zan:field:submit]', event.detail.value);
- this.showZanTopTips(`选中的值为${event.detail.value.formtest}`);
}
}));
diff --git a/example/pages/select/index.json b/example/pages/select/index.json
index 87a16f34..30dbc616 100644
--- a/example/pages/select/index.json
+++ b/example/pages/select/index.json
@@ -1,7 +1,8 @@
{
"navigationBarTitleText": "Select 选择",
"usingComponents": {
- "zan-panel": "/packages/panel/index",
- "zan-select": "/packages/select/index"
+ "doc-page": "../../components/doc-page/index",
+ "zan-panel": "../../dist/panel/index",
+ "zan-select": "../../dist/select/index"
}
}
diff --git a/example/pages/select/index.wxml b/example/pages/select/index.wxml
index 0061af5a..743976c1 100644
--- a/example/pages/select/index.wxml
+++ b/example/pages/select/index.wxml
@@ -1,24 +1,20 @@
-
-
-
-
- SELECT
-
+
-
-
+
diff --git a/packages/select/README.md b/packages/select/README.md
index f6627d5b..6fd2dcb9 100644
--- a/packages/select/README.md
+++ b/packages/select/README.md
@@ -16,7 +16,7 @@
items="{{ items }}"
checkedValue="{{ checkedValue }}"
activeColor="{{ activeColor }}"
- bind:change="handleFieldChange"
+ bind:change="handleSelectChange"
/>
```
```js
@@ -24,15 +24,11 @@ Page({
data: {
items: [
{
- // 当前选项离左侧的距离
- padding: 0,
- // 当前选项的值,在被选中时,会在 handleZanSelectChange 中获取到
value: '1',
// 选项文案
name: '选项一',
},
{
- padding: 0,
value: '2',
name: '选项二',
},
@@ -42,8 +38,8 @@ Page({
},
methods: {
- handleFieldChange(event, data) {
- console.log(event, data);
+ handleSelectChange({ detail }) {
+ console.log(detail);
}
}
});
@@ -57,3 +53,21 @@ Page({
| items | select 显示各个项的配置 | Array | - | |
| checkedValue | 高亮的 item 的 value 值 | String | - | |
| activeColor | Select 高亮颜色 | String | #ff4444 | |
+
+items 具体格式如下
+```js
+{
+ items: [
+ {
+ // 选项选中时,代表的选中值。会以此作为唯一值,判断是否选中
+ value: '1',
+ // 选项的文字描述
+ name: '选项一',
+ },
+ {
+ value: '2',
+ name: '选项二',
+ },
+ ]
+}
+```
diff --git a/packages/select/index.js b/packages/select/index.js
index 5b789b2f..9e4a617b 100644
--- a/packages/select/index.js
+++ b/packages/select/index.js
@@ -19,9 +19,9 @@ Component({
},
methods: {
- _handleZanSelectChange(e) {
+ handleSelectChange(e) {
const value = e.detail.value;
- this.triggerEvent('change', event, { value });
+ this.triggerEvent('change', { value });
}
}
});
diff --git a/packages/select/index.pcss b/packages/select/index.pcss
index 0695dae7..36382a85 100644
--- a/packages/select/index.pcss
+++ b/packages/select/index.pcss
@@ -1,3 +1,8 @@
.zan-select__list .zan-select__radio{
- display: none;
+ position: absolute;
+ top: 0;
+ bottom: 0;
+ left: 0;
+ right: 0;
+ opacity: 0;
}
diff --git a/packages/select/index.wxml b/packages/select/index.wxml
index 37deeff1..7d0ce062 100644
--- a/packages/select/index.wxml
+++ b/packages/select/index.wxml
@@ -1,6 +1,6 @@