我按照官网H5+的案例
5+案例
nTitle = contentWebview.getNavigationbar();
console.log(JSON.stringify(nTitle));
nTitle.interceptTouchEvent(true);
log
[LOG] : {"__id__":"Navigationbar","__uuid__":"_Nav_Bar_NWindow61487470387006"}
我在测试工程上
var contentWebview = plus.webview.create('http://m.weibo.cn/u/3196963860', 'contendWebview', {'navigationbar':{'backgroundcolor':'#f7f7f7','titletext':'标题','titlecolor':'#000000'}});
setTimeout(function(){
var nTitle = contentWebview.getNavigationbar();
console.log(JSON.stringify(nTitle));
},200);
log
[LOG] :
打印出为空,求为什么呀
完全不懂,why,需要哪里配置吗
3 个回复
DCloud_heavensoft
首页的navigationbar是在manifest里配置的。
二级页是在create webview时设置。
Hello H5+示例的nativeObj里是在create里设置。
Hello mui示例的首页就是原生title,是在manifest里设置的,以及Hello mui里的nar bar里的native title也是。
打包时,需要在manifest里选择nativeObj模块。
这些问题都不是,就检查代码哪里有错,符号之类的注意。
我在手机上,没仔细看你的代码,但粗看下不应该使用定时器,create有成功回调,以及在定时器里var一个变量不好。
8***@qq.com
关于“Hello H5+示例的nativeObj里是在create里设置。Hello mui示例的首页就是原生title,是在manifest里设置的”,能说得明白一点儿吗?
比如我在manifest没有找到对应设置的地方,在create里又是用哪个参数设置的?
DCloud_heavensoft
manifest里有titlenview节点,搜一下
2018-06-05 10:01
8***@qq.com
好的,谢谢
2018-07-05 17:07
8***@qq.com
Manifest的做法就是在"plus": {"launchwebview": {中增加如下内容:
"titleNView": {
"backgroundcolor": "#f7f7f7",
"titletext": "首页",
"titlecolor": "#000000"
}
然后,在plusready中
_self = plus.webview.currentWebview();
var titleView = _self.getNavigationbar();
可参考Hbuilder自带的例子程序。