Browse Source

开关组件

zhaoxiaohai 3 years ago
parent
commit
71596522fd
1 changed files with 4 additions and 1 deletions
  1. 4 1
      components/My_switch/index.js

+ 4 - 1
components/My_switch/index.js

@@ -7,6 +7,9 @@ Component({
         list: {
             type: Array,
             value: ['最新', '最热']
+        },
+        change: {
+            type: Function
         }
     },
     lifetimes: {
@@ -40,7 +43,7 @@ Component({
             this.setData({
                 checkedItem: this.data.checkedItem == 0 ? 1 : 0
             })
-            console.log(this.data.list[this.data.checkedItem])
+            this.triggerEvent('change', this.data.list[this.data.checkedItem])
             this.chengeSelect()
         },
         chengeSelect() {