uniapp里的mounted_uni-app自定义组件:1、简单加载等待

直接上源码,

注意的坑

1、小程序的 watch 监听不能用,在H5 平台这样没问题,反正就是这玩意不好用。

2、父组件调用子组件的方法得放到mounted里,不然就是undefined

加载组件

{ { loading_title }}

{ { loading_title }}

/*

名称:简单全屏loading

日期:2020-02-25

作者:hj

目标:支持微信小程序、web、app

*/

export default {

name: "pre_loading_full",

data() {

return {

show_loading: false,

show_wx_loading: false,

t_height: 0,

t_width: 0,

loading_title: '玩命加载中'

};

},

// watch 不好用,换方法

// 小程序的 watch 监听不能用,在H5 平台这样没问题

// watch: {

// pre_show_loading(val) {

// console.log('监视 '+val);

// if(val=='false'){

// this.show_loading=false;

// }else{

// this.show_loading=true;

// }

// this.beginLoading();

// }

// },

methods: {

pre_loading: function(val) {

var type = '';

type = uni.getSystemInfoSync().platform;

console.log('开始加载。。。。。。。。。' + type);

if (type == 'android' || type == 'ios') {

console.log('运行' + type + '上');

this.show_loading = val?true:false;

this.beginLoading();

} else if (type == 'devtools') {

console.log('运行在开发者工具上');

console.log('可用宽度=' + uni.getSystemInfoSync().windowWidth);

this.show_loading = false;

this.show_wx_loading = val?true:false;

if(this.show_wx_loading){

this.t_height = uni.getSystemInfoSync().windowHeight;

this.t_width = uni.getSystemInfoSync().windowWidth;

}else{

this.t_height=0;

this.t_width=0;

}

this.beginLoading2();

} else {

console.log('运行' + type + '上');

this.show_loading = val?true:false;;

this.beginLoading();

}

},

beginLoading: function() {

var bl;

var num = 1;

var that = this;

bl = setInterval(function() {

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值