在A页面 :
// 创建id为'test'的view
new plus.nativeObj.View('test');
// 获取id为'test'的view 并打印是正常获取到的
// [LOG] : {"__id__":"test","__uuid__":"NativeView81488330298019"}
console.log(JSON.stringify(plus.nativeObj.View.getViewById('test')));
然而...
在A页面:
// 创建id为'test'的view
new plus.nativeObj.View('test');
// 创建B页面
plus.webview.create(...).show();
// 然后在B页面获取id为'test'的view打印出来是空的, 什么都没有,这是怎么回事。
// B页面只是单纯的创建并show了一下.
// 所有操作都是在plusReady之后的。
console.log(JSON.stringify(plus.nativeObj.View.getViewById('test'))); // 打印是空的
这是什么诡异问题?
// 完整代码
// a页面
mui.plusReady(function() {
new plus.nativeObj.View('test');
// 获取到的
console.log(JSON.stringify(plus.nativeObj.View.getViewById('test')));
var b = plus.webview.create('b.html', 'b');
b.addEventListener('loaded', function() {
b.show();
}, false);
});
//b页面
mui.plusReady(function() {
// 获取不到, 空的
console.log(JSON.stringify(plus.nativeObj.View.getViewById('test')));
});

超人爷爷
- 发布:2017-03-01 09:11
- 更新:2019-02-23 15:44
- 阅读:2418
2 个回复
超人爷爷 (作者)
来个人确认下问题...
用户距离您30米 - 98IT
你好, 你这个问题解决了吗,怎么解决的