Browse Source

feat: 组件文档更新 (#522)

Co-authored-by: yangxiaolu3 <yangxiaolu3@jd.com>
yangxiaolu1993 4 years ago
parent
commit
6cdd864eff

+ 0 - 1
src/config.json

@@ -634,7 +634,6 @@
         {
           "version": "3.0.0",
           "taro": true,
-          "tarodoc": true,
           "name": "Address",
           "type": "component",
           "cName": "地址",

+ 3 - 1
src/packages/__VUE/address/doc.md

@@ -8,8 +8,10 @@
 
 ``` javascript
 import { createApp } from 'vue';
+//vue
 import { Address, Icon, Popup } from '@nutui/nutui';
-
+//mp
+import { Address, Icon, Popup } from '@nutui/nutui@taro';
 const app = createApp();
 app.use(Address);
 app.use(Icon);

+ 0 - 416
src/packages/__VUE/address/doc.taro.md

@@ -1,416 +0,0 @@
-#  Address组件
-
-### 介绍
-
-按需加载请加载对应依赖组件 Icon Popup
-
-### 安装
-
-``` javascript
-import { createApp } from 'vue';
-import { Address, Icon, Popup } from '@nutui/nutui';
-
-const app = createApp();
-app.use(Address);
-app.use(Icon);
-app.use(Popup);
-
-```
-
-## 代码演示
-
-### 选择自定义地址
-
-```html
-<nut-cell title="选择地址" :desc="text" is-link @click="showAddress"></nut-cell>
-<nut-address
-    v-model:visible="showPopup"
-    :province="province"
-    :city="city"
-    :country="country"
-    :town="town"
-    @change="onChange"
-    @close="close"
-    custom-address-title="请选择所在地区"
-></nut-address>
-```
-```javascript
-setup() {
-    const showPopup = ref(false);
-    const address = reactive({
-      province:[
-        { id: 1, name: '北京' },
-        { id: 2, name: '广西' },
-        { id: 3, name: '江西' },
-        { id: 4, name: '四川' }
-      ],
-      city:[
-        { id: 7, name: '朝阳区' },
-        { id: 8, name: '崇文区' },
-        { id: 9, name: '昌平区' },
-        { id: 6, name: '石景山区' }
-      ],
-      country:[
-        { id: 3, name: '八里庄街道' },
-        { id: 9, name: '北苑' },
-        { id: 4, name: '常营乡' }
-      ],
-      town:[]
-    })
-
-    const text = ref('请选择地址')
-
-    const showAddress = () => {
-      showPopup.value = !showPopup.value;
-    };
-
-    const onChange = (cal) => {
-      const name = address[cal.next]
-      if (name.value.length < 1) {
-        showPopup.value = false;
-      }
-    };
-    const close = val => {
-      console.log(val);
-      text.value = val.data.addressStr;
-    };
-
-    return { showPopup, text, showAddress, onChange, close, ...toRefs(address) };
-}
-```
-
-### 选择已有地址
-
-```html
-<nut-cell title="选择地址" :desc="text" is-link @click="showAddressExist"></nut-cell>
-<nut-address
-    v-model:visible="showPopupExist"
-    type="exist"
-    :exist-address="existAddress"
-    @close="close"
-    :is-show-custom-address="false"
-    @selected="selected"
-    exist-address-title="配送至"
-></nut-address>
-```
-```javascript
-setup() {
-    const showPopupExist = ref(false);
-    const existAddress = ref([
-      {
-        id: 1,
-        addressDetail: 'th ',
-        cityName: '石景山区',
-        countyName: '城区',
-        provinceName: '北京',
-        selectedAddress: true,
-        townName: ''
-      },{
-        id: 2,
-        addressDetail: '12_ ',
-        cityName: '电饭锅',
-        countyName: '扶绥县',
-        provinceName: '北京',
-        selectedAddress: false,
-        townName: ''
-      },{
-        id: 3,
-        addressDetail: '发大水比 ',
-        cityName: '放到',
-        countyName: '广宁街道',
-        provinceName: '钓鱼岛全区',
-        selectedAddress: false,
-        townName: ''
-      },{
-        id: 4,
-        addressDetail: '还是想吧百度吧 ',
-        cityName: '研发',
-        countyName: '八里庄街道',
-        provinceName: '北京',
-        selectedAddress: false,
-        townName: ''
-      }
-    ]);
-
-    const text = ref('请选择地址')
-
-    const showAddressExist = () => {
-      showPopupExist.value = true;
-    };
-
-    const close = val => {
-      if (val.type == 'exist') {
-        const {provinceName,cityName,countyName,townName,addressDetail} = val.data
-        text.value = provinceName + cityName + countyName + townName + addressDetail;
-      } else {
-        text.value = val.data.addressStr;
-      }
-    };
-
-    const selected = (prevExistAdd, nowExistAdd, arr) => {
-      console.log(prevExistAdd);
-      console.log(nowExistAdd);
-    };
-
-    return { showPopupExist, existAddress, showAddressExist, text, close, selected };
-}
-```
-### 自定义图标
-
-```html
-<nut-cell title="选择地址" :desc="text" is-link @click="showCustomImg"></nut-cell>
-<nut-address
-    v-model:visible="showPopupCustomImg"
-    type="exist"
-    :existAddress="existAddress"
-    @close="close"
-    :is-show-custom-address="false"
-    @selected="selected3"
-    :default-icon="defaultIcon"
-    :selected-icon="selectedIcon"
-    :close-btn-icon="closeBtnIcon"
-></nut-address>
-```
-```javascript
-setup() {
-    const showPopupCustomImg = ref(false);
-    const icon = reactive({
-      selectedIcon: 'heart-fill',
-      defaultIcon: 'heart1',
-      closeBtnIcon: 'close',
-      backBtnIcon: 'left'
-    });
-    const existAddress = ref([
-      {
-        id: 1,
-        addressDetail: 'th ',
-        cityName: '石景山区',
-        countyName: '城区',
-        provinceName: '北京',
-        selectedAddress: true,
-        townName: ''
-      },{
-        id: 2,
-        addressDetail: '12_ ',
-        cityName: '电饭锅',
-        countyName: '扶绥县',
-        provinceName: '北京',
-        selectedAddress: false,
-        townName: ''
-      },{
-        id: 3,
-        addressDetail: '发大水比 ',
-        cityName: '放到',
-        countyName: '广宁街道',
-        provinceName: '钓鱼岛全区',
-        selectedAddress: false,
-        townName: ''
-      },{
-        id: 4,
-        addressDetail: '还是想吧百度吧 ',
-        cityName: '研发',
-        countyName: '八里庄街道',
-        provinceName: '北京',
-        selectedAddress: false,
-        townName: ''
-      }
-    ]);
-
-    const text = ref('请选择地址')
-
-    const showCustomImg = () => {
-      showPopupCustomImg.value = true;
-    };
-
-    const close = val => {
-      if (val.type == 'exist') {
-        const {provinceName,cityName,countyName,townName,addressDetail} = val.data
-        text.value = provinceName + cityName + countyName + townName + addressDetail;
-      } else {
-        text.value = val.data.addressStr;
-      }
-    };
-
-    const selected = (prevExistAdd, nowExistAdd, arr) => {
-      console.log(prevExistAdd);
-      console.log(nowExistAdd);
-    };
-
-    return { showPopupCustomImg, existAddress, text, showCustomImg, close, selected, ...toRefs(icon) };
-}
-```
-### 自定义地址与已有地址切换
-
-```html
-<nut-cell title="选择地址" :desc="text" is-link @click="showAddressOther"></nut-cell>
-<nut-address
-    v-model:visible="showPopupOther"
-    type="exist"
-    :exist-address="existAddress"
-    :province="province"
-    :city="city"
-    :country="country"
-    :town="town"
-    :back-btn-icon="backBtnIcon"
-    @close="close"
-    @selected="selected"
-    custom-and-exist-title="选择其他地址"
-    @switch-module="switchModule"
-    @close-mask="closeMask"
-></nut-address>
-```
-```javascript
-setup() {
-    const showPopupOther = ref(false);
-    const address = reactive({
-      province:[
-        { id: 1, name: '北京' },
-        { id: 2, name: '广西' },
-        { id: 3, name: '江西' },
-        { id: 4, name: '四川' }
-      ],
-      city:[
-        { id: 7, name: '朝阳区' },
-        { id: 8, name: '崇文区' },
-        { id: 9, name: '昌平区' },
-        { id: 6, name: '石景山区' }
-      ],
-      country:[
-        { id: 3, name: '八里庄街道' },
-        { id: 9, name: '北苑' },
-        { id: 4, name: '常营乡' }
-      ],
-      town:[]
-    })
-    const existAddress = ref([
-      {
-        id: 1,
-        addressDetail: 'th ',
-        cityName: '石景山区',
-        countyName: '城区',
-        provinceName: '北京',
-        selectedAddress: true,
-        townName: ''
-      },
-      {
-        id: 2,
-        addressDetail: '12_ ',
-        cityName: '电饭锅',
-        countyName: '扶绥县',
-        provinceName: '北京',
-        selectedAddress: false,
-        townName: ''
-      },
-      {
-        id: 3,
-        addressDetail: '发大水比 ',
-        cityName: '放到',
-        countyName: '广宁街道',
-        provinceName: '钓鱼岛全区',
-        selectedAddress: false,
-        townName: ''
-      },
-      {
-        id: 4,
-        addressDetail: '还是想吧百度吧 ',
-        cityName: '研发',
-        countyName: '八里庄街道',
-        provinceName: '北京',
-        selectedAddress: false,
-        townName: ''
-      }
-    ]);
-    const backBtnIcon = ref('left')
-    const text = ref('请选择地址')
-
-    const showAddressOther = () => {
-      showPopupOther.value = true;
-    };
-
-    const close = val => {
-      if (val.type == 'exist') {
-        const {provinceName,cityName,countyName,townName,addressDetail} = val.data
-        text.value = provinceName + cityName + countyName + townName + addressDetail;
-      } else {
-        text.value = val.data.addressStr;
-      }
-    };
-
-    const selected = (prevExistAdd, nowExistAdd, arr) => {
-      console.log(prevExistAdd);
-      console.log(nowExistAdd);
-    };
-
-    const switchModule = cal => {
-      if (cal.type == 'custom') {
-        console.log('点击了“选择其他地址”按钮');
-      } else {
-        console.log('点击了自定义地址左上角的返回按钮');
-      }
-    };
-
-    const closeMask = val => {
-      console.log('关闭弹层', val);
-    };
-
-    return { showPopupOther, text, showAddressOther, switchModule, closeMask, close, selected, backBtnIcon, ...toRefs(address) };
-}
-```
-# API
-
-| 字段 | 说明 | 类型 | 默认值
-|----- | ----- | ----- | ----- 
-| v-model:visible | 是否打开地址选择 | String | ''
-| type | 地址选择类型 exist/custom | String | 'custom'
-| province | 省,每个省的对象中,必须有 name 字段 | Array | []
-| city | 市,每个市的对象中,必须有 name 字段 | Array | []
-| country | 县,每个县的对象中,必须有 name 字段 | Array | []
-| town | 乡/镇,每个乡/镇的对象中,必须有 name 字段 | Array | []
-| exist-address | 已存在地址列表,每个地址对象中,必传值provinceName、cityName、countyName、townName、addressDetail、selectedAddress(字段解释见下) | Array | []
-| default-icon | 已有地址列表默认图标,type=‘exist’ 时生效 | string | ''
-| selected-icon | 已有地址列表选中图标,type=‘exist’ 时生效 | string | ''
-| close-btn-icon | 自定义关闭弹框按钮图标 | string | -
-| back-btn-icon | 自定义地址与已有地址切换时,自定义返回的按钮图标 | string | -
-| is-show-custom-address | 是否可以切换自定义地址选择,type=‘exist’ 时生效 | Boolean | true
-| custom-address-title  | 自定义地址选择文案,type='custom' 时生效 | string | '请选择所在地区'
-| exist-address-title| 已有地址文案 ,type=‘exist’ 时生效| string | '配送至'
-| custom-and-exist-title| 自定义地址与已有地址切换按钮文案 ,type=‘exist’ 时生效| string | '选择其他地址'
-
-
-  * provinceName 省的名字
-  * cityName 市的名字
-  * countyName 县的名字
-  * townName 乡/镇的名字
-  * addressDetail 具体地址
-  * selectedAddress 字段用于判断当前地址列表的选中项。
-
-## Event
-| 字段 | 说明 | 回调参数 
-|----- | ----- | ----- 
-| change | 自定义选择地址时,选择地区时触发 |  参考 onChange
-| selected | 选择已有地址列表时触发 | 参考 selected
-| close | 地址选择弹框关闭时触发 | 参考 close
-| close-mask |点击遮罩层或点击右上角叉号关闭时触发 | {closeWay:'mask'/'cross'}
-| switch-module | 点击‘选择其他地址’或自定义地址选择左上角返回按钮触发 | {type:'exist'/'custom'}
-
-
-## change 回调参数
-| 参数 | 说明 | 可能值 
-|----- | ----- | ----- 
-| custom | 当前点击的行政区域  |  province(省) / city(市) / country(县) / town(乡)
-| next | 当前点击的行政区域的下一级 | province(省) / city(市) / country(县) / town(乡)
-| value | 当前点击的行政区域的值(返回传入的值) | {}
-
-## selected 回调参数
-| 参数 | 说明 | 可能值 
-|----- | ----- | ----- 
-| 第一个参数(prevExistAdd) |  选择前选中的地址 |  {}
-| 第二个参数(nowExistAdd) |  当前选中的地址 |  {}
-| 第三个参数(arr) |  选择完之后的已有地址列表(selectedAddress 值发生改变) |  {}
-
-## close 回调参数
-| 参数 | 说明 | 可能值 
-|----- | ----- | ----- 
-| type | 地址选择类型 exist/custom  |  exist/custom
-| data | 选择地址的值,custom 时,addressStr 为选择的地址组合 | {} 
-    

+ 40 - 120
src/packages/__VUE/infiniteloading/doc.taro.md

@@ -8,7 +8,7 @@
 
 ```javascript
   import { createApp } from 'vue';
-  import { InfiniteLoading } from '@nutui/nutui';
+  import { InfiniteLoading } from '@nutui/nutui@taro';
 
   const app = createApp();
   app.use(InfiniteLoading);
@@ -18,153 +18,76 @@
     
 ### 基础用法
 
-```html
-<ul class="infiniteUl" id="scroll">
-    <nut-infiniteloading
-        containerId = 'scroll'
-        :use-window='false'
-        :has-more="hasMore"
-        @load-more="loadMore"
-    >
-        <li class="infiniteLi" v-for="(item, index) in defultList" :key="index">{{item}}</li>
-    </nut-infiniteloading>
-</ul>
-```
-```javascript
-setup() {
-    const hasMore = ref(true);
-    const data = reactive({
-      defultList: []
-    });
-    const loadMore = done => {  
-      setTimeout(() => {
-        const curLen = data.defultList.length;
-        for (let i = curLen; i < curLen + 10; i++) {
-          data.defultList.push(`${i}`);
-        }
-        if (data.defultList.length > 30) hasMore.value = false;
-        done()
-      }, 500);
-    };
-    const init = () => {
-      for (let i = 0; i < 10; i++) {
-        data.defultList.push(`${i}`);
-      }
-    }
-    onMounted(() => {
-      init()
-    });
-    return { loadMore, hasMore, ...toRefs(data) };
-}
-```
-### 下拉刷新
+在一个页面中,只能有一个 Infiniteloading,不可同时存在两个以及更多。
 
 ```html
-<ul class="infiniteUl" id="refreshScroll">
+<div class="infiniteUl" id="scrollDemo">
   <nut-infiniteloading
     pull-icon="JD"
-    container-id="refreshScroll"
-    :use-window="false"
+    load-txt="loading"
+    load-more-txt="没有啦~"
     :is-open-refresh="true"
-    :has-more="refreshHasMore"
-    @load-more="refreshLoadMore"
+    container-id="scrollDemo"
+    :has-more="hasMore"
+    @load-more="loadMore"
     @refresh="refresh"
   >
-    <li
+    <div
       class="infiniteLi"
-      v-for="(item, index) in refreshList"
+      v-for="(item, index) in defultList"
       :key="index"
-      >{{ item }}</li
+      >{{ item }}</div
     >
   </nut-infiniteloading>
-</ul>
+</div>
 ```
 ```javascript
 setup() {
-    const refreshHasMore = ref(true);
+    const hasMore = ref(true);
+
     const data = reactive({
-      refreshList: []
+      defultList: ['']
     });
-    const refreshLoadMore = done => {
+
+    const loadMore = (done) => {
       setTimeout(() => {
-        const curLen = data.refreshList.length;
+        const curLen = data.defultList.length;
+
         for (let i = curLen; i < curLen + 10; i++) {
-          data.refreshList.push(
-            `${i}`
-          );
+          data.defultList.push(`${i}`);
         }
-        if (data.refreshList.length > 30) refreshHasMore.value = false;
-        done()
+
+        if (data.defultList.length > 30) hasMore.value = false;
+
+        done();
       }, 500);
     };
 
     const refresh = (done) => {
-      setTimeout(()=>{
-        Toast.success('刷新成功');
-        done()
-      },1000)
-    }
-    const init = () => {
-      for (let i = 0; i < 10; i++) {
-        data.refreshList.push(`${i}`);
-      }
-    }
-    onMounted(() => {
-      init()
-    });
-    return { refreshLoadMore, refreshHasMore, refresh, ...toRefs(data) };
-}
-```
-### 自定义加载文案
-
-```html
-<ul class="infiniteUl" id="customScroll">
-    <nut-infiniteloading
-        container-id = 'customScroll'
-        :use-window='false'
-        :has-more="customHasMore"
-        @load-more="customLoadMore"
-    >
-        <li class="infiniteLi" v-for="(item, index) in customList" :key="index">{{item}}</li>
-        <template v-slot:loading>
-            <div class="loading">
-                <span>加载中...</span>
-            </div>
-        </template>
-        <template v-slot:unloadMore>
-            <div class="unload-more">没有数据啦 ~~</div>
-        </template>
-    </nut-infiniteloading>
-</ul>
-```
-```javascript
-setup() {
-    const customHasMore = ref(true);
-    const data = reactive({
-      customList: ['']
-    });
-    const customLoadMore = done => {
       setTimeout(() => {
-        const curLen = data.customList.length;
-        for (let i = curLen; i < curLen + 10; i++) {
-          data.customList.push(`${i}`);
-        }
-        if (data.customList.length > 30) customHasMore.value = false;
-        done()
-      }, 500);
+        console.log('刷新成功');
+        done();
+      }, 1000);
     };
+
     const init = () => {
-      for (let i = 0; i < 10; i++) {
-        data.customList.push(`${i}`);
+      for (let i = 0; i < 20; i++) {
+        data.defultList.push(`${i}`);
       }
-    }
+    };
     onMounted(() => {
-      init()
+      init();
     });
-    return { customHasMore, customLoadMore,...toRefs(data) };
+    return {
+      loadMore,
+      hasMore,
+      refresh,
+      ...toRefs(data)
+    };
 }
 ```
 
+
 ## API
 
 ### Props
@@ -172,10 +95,7 @@ setup() {
 | 参数         | 说明                             | 类型   | 默认值           |
 |--------------|----------------------------------|--------|------------------|
 | has-more         | 是否还有更多数据               | Boolean | `true`                |
-| threshold         | 距离底部多远加载 | Number | `200`               |
-| use-window | 将滚动侦听器添加到 window 否则侦听组件的父节点     | Boolean | `true` |
-| use-capture          | 是否使用捕获模式 true 捕获 false 冒泡                        | Boolean | `false`            |
-| container-id          | 在 useWindow 属性为 false 的时候,自定义设置节点ID                        | String | `''`            |
+| container-id          | 必填,设置滚动节点ID                        | String | `''`            |
 | load-more-txt          | “没有更多数”据展示文案                        | String | `'哎呀,这里是底部了啦'`            |
 | is-open-refresh        | 是否开启下拉刷新                         | Boolean | `false`                |
 | pull-icon        | 下拉刷新[图标名称](#/icon)                        | String | <img src="https://img10.360buyimg.com/imagetools/jfs/t1/169863/6/4565/6306/60125948E7e92774e/40b3a0cf42852bcb.png" width=40/>                |