g***@163.com
g***@163.com
  • 发布:2019-05-15 18:28
  • 更新:2019-05-16 08:28
  • 阅读:3168

uniapp在IOS中动态设置标题栏按钮无效问题(android下有效)

分类:uni-app

问题如题,详细如下描述,请大神帮忙解答。

HBuilderX版本: 1.9.4.20190426

app中一个新增会员和查看会员公用功能的页面,根据页面参数 动态设置按钮的js代码如下:

    computed: {  
        shiftNavBtn(){   
            // #ifdef APP-PLUS    
            let pages = getCurrentPages();    
            let page = pages[pages.length - 1];   

            let currentWebview = page.$getAppWebview(); //plus.webview.currentWebview();    
            let titleObj = currentWebview.getStyle().titleNView;  
            **console.log('currentWebview.getStyle():' + JSON.stringify(currentWebview.getStyle()))**  
            // console.log('titleObj.buttons:' + JSON.stringify(titleObj))  
            if (!titleObj.buttons) {  
                return;  
            }    
            //icon 码使用未成功 此次改用文字  
            if(this.sourceType === service.SOURCE_TYPE.MEMBER_UPDATE){  
                titleObj.buttons[0].text = this.modifyFlag ? "确定" : "修改"; // "hi";   \ue60e ok   ue6fc modify  
            }else{  
                titleObj.buttons[0].text = "确定";  
            }  
            currentWebview.setStyle({    
                titleNView: titleObj    
            });    
            // #endif   
            return false;  
        }  
    },  

android下上述代码打印日志显示有button信息,如下:

currentWebview.getStyle():{"render":"always","kernel":"WKWebview","videoFullscreen":"landscape","top":0,"bottom":0,"bounce":"vertical","keyboardDisplayRequiresUserAction":false,"navigationBarTextStyle":"white","navigationBarBackgroundColor":"#333","name":"3","backgroundColor":"#eee","usingComponents":{},"navigationBarTitleText":"新建会员",
"titleNView":{"autoBackButton":true,"type":"default","backgroundColor":"#333","titleText":"新增会员","titleColor":"#FFFFFF","buttons":[{"fontSrc":"/static/iconfonts/iconfont.ttf","text":"","fontSize":"16px","cb":{"id":"plus221557914200792","htmlId":"70839883"}}],
"titleSize":"17px"}}

ios下打印日志显示无任何button信息(也就无法动态设置按钮文字),如下:
currentWebview.getStyle():{"top":0,"bounce":"vertical","left":0,"keyboardDisplayRequiresUserAction":false,"navigationBarTextStyle":"white","zindex":0,"kernel":"WKWebview","navigationBarBackgroundColor":"#333","width":414,"opacity":1,"background":"RGBA(255, 255, 255, 1)","videoFullscreen":"landscape","height":736,"bottom":0,
"titleNView":{},
"name":"5","render":"always"}

2019-05-15 18:28 负责人:无 分享
已邀请:
DCloud_UNI_CHB

DCloud_UNI_CHB

补充HBuilderX版本信息

  • g***@163.com (作者)

    感谢帮助,我的HBuilderX版本是 1.9.4.20190426

    2019-05-16 10:52

该问题目前已经被锁定, 无法添加新回复