diff --git a/example/pages/toptips/index.js b/example/pages/toptips/index.js index 62926a82..79f6d0e0 100644 --- a/example/pages/toptips/index.js +++ b/example/pages/toptips/index.js @@ -1,9 +1,44 @@ -var Zan = require('../../dist/index'); +const Toptips = require('../../dist/toptips/index'); -Page(Object.assign({}, Zan.TopTips, { - data: {}, +Page({ + data: { + content: '测试toptips', + duration: 2000, + $zanui: { + toptips: { + show: false + } + } + }, showTopTips() { - this.showZanTopTips('toptips的内容'); + this.setData({ + $zanui: { + toptips: { + show: true + } + } + }); + + setTimeout(() => { + this.setData({ + $zanui: { + toptips: { + show: false + } + } + }); + },this.data.duration); + }, + + showTopTips2() { + Toptips('测试内容'); + }, + + showTopTips3() { + Toptips({ + duration: 1000, + content: '测试时间1秒' + }) } -})); +}); diff --git a/example/pages/toptips/index.json b/example/pages/toptips/index.json index 3f45367d..a2099cd9 100644 --- a/example/pages/toptips/index.json +++ b/example/pages/toptips/index.json @@ -1,3 +1,6 @@ { - "navigationBarTitleText": "Toptips 顶部提示" + "navigationBarTitleText": "Toptips 顶部提示", + "usingComponents": { + "zan-toptips": "../../dist/toptips/index" + } } diff --git a/example/pages/toptips/index.wxml b/example/pages/toptips/index.wxml index bc84428d..8e40027f 100644 --- a/example/pages/toptips/index.wxml +++ b/example/pages/toptips/index.wxml @@ -6,9 +6,25 @@ + + + + + + + + - + diff --git a/packages/noticebar/index.js b/packages/noticebar/index.js index 4b0a8ca2..7c0c67f2 100644 --- a/packages/noticebar/index.js +++ b/packages/noticebar/index.js @@ -66,6 +66,11 @@ Component({ } }, + detached() { + const { timer } = this.data; + timer && clearTimeout(timer); + }, + ready() { this._init(); }, @@ -105,7 +110,6 @@ Component({ if (scrollable && wrapWidth < width) { const elapse = width / speed * 1000; - console.log(`delay: ${delay}`) const animation = wx.createAnimation({ duration: elapse, timeingFunction: 'linear', @@ -162,4 +166,4 @@ Component({ }); } } -}) \ No newline at end of file +}) diff --git a/packages/tab/index.js b/packages/tab/index.js index 37c9b6ab..23568383 100644 --- a/packages/tab/index.js +++ b/packages/tab/index.js @@ -20,31 +20,16 @@ Component({ }, selectedId: { type: [String, Number], - value: '', - observer(newVal) { - this.setData({ - currentTab: newVal - }); - } + value: '' } }, - data: { - currentTab: '' - }, - - attached() { - this.setData({ - currentTab: this.data.selectedId - }); - }, - methods: { _handleZanTabChange(e) { const selectedId = e.currentTarget.dataset.itemId; this.setData({ - currentTab: selectedId + selectedId }); console.info('[zan:tab:change] selectedId:', selectedId); diff --git a/packages/tab/index.wxml b/packages/tab/index.wxml index 60474ed1..1a52111e 100644 --- a/packages/tab/index.wxml +++ b/packages/tab/index.wxml @@ -10,7 +10,7 @@ >