guhongwei hace 2 años
padre
commit
98d5b552e2
Se han modificado 3 ficheros con 30 adiciones y 1 borrados
  1. 12 0
      pages/test/index.js
  2. 2 1
      pages/test/index.json
  3. 16 0
      pages/test/index.wxml

+ 12 - 0
pages/test/index.js

@@ -14,6 +14,13 @@ Page({
         // dialog弹框
         dialog: { title: '弹框标题', show: false, type: '1' },
         form: {},
+        tabs: {
+            active: 'a',
+            menu: [
+                { title: '选项一', active: 'a' },
+                { title: '选项二', active: 'b' },
+            ],
+        },
     },
     initValidate() {
         const rules = { start_time: { required: true } }
@@ -73,6 +80,11 @@ Page({
             console.log(params);
         }
     },
+    tabsChange: function (e) {
+        const that = this;
+        let { active } = e.detail;
+        that.setData({ 'tabs.active': active });
+    },
     /**
      * 生命周期函数--监听页面加载
      */

+ 2 - 1
pages/test/index.json

@@ -4,6 +4,7 @@
         "mobile-main": "/commpents/mobile-frame/index",
         "upload": "/commpents/upload/index",
         "dialog": "/commpents/dialog/index",
-        "datatime-picker": "/commpents/datetime-picker/index"
+        "datatime-picker": "/commpents/datetime-picker/index",
+        "s-tab": "/commpents/tabs/index"
     }
 }

+ 16 - 0
pages/test/index.wxml

@@ -23,6 +23,22 @@
                 </view>
             </form>
         </view>
+        <view class="zero">
+            <form catchsubmit="toSubmit">
+                <view>选项卡</view>
+                <view>
+                    <s-tab tabs="{{tabs}}" bind:tabsChange="tabsChange"></s-tab>
+                </view>
+                <view>
+                    <view wx:if="{{tabs.active=='a'}}">
+                        1
+                    </view>
+                    <view wx:elif="{{tabs.active=='b'}}">
+                        2
+                    </view>
+                </view>
+            </form>
+        </view>
     </view>
 </mobile-main>
 <dialog dialog="{{dialog}}" bind:toClose="toClose">