123456789101112131415161718192021222324252627282930313233343536373839404142 |
- let timer;
- Component({
- externalClasses: ['tui-tips-class'],
- properties: {
- //top bottom center
- position: {
- type: String,
- value: "top"
- }
- },
- data: {
- show: false,
- msg: "无法连接到服务器~",
- //translucent,primary,green,warning,danger
- type: "translucent"
- },
- lifetimes: {
- detached: function() {
- clearTimeout(timer);
- timer = null;
- }
- },
- methods: {
- showTips: function(options) {
- const {type = 'translucent', duration = 2000} = options;
- clearTimeout(timer);
- this.setData({
- show: true,
- type: type,
- msg: options.msg
- }, () => {
- timer = setTimeout(() => {
- this.setData({
- show: false
- }, () => {
- timer = null;
- })
- }, duration)
- })
- }
- }
- })
|