@DCloud_MUI_CHB
aaa.html 打开 test-header 的代码:
document.getElementById('history').addEventListener('tap', function (e) {
mui.openWindow({
url: './views/history-header.html',
id: 'history-header'
});
});
test-header append test-body 的代码:
var header = plus.webview.currentWebview();
var body = plus.webview.create('./history-body.html', 'history-body', {top: '48px', bottom: '0px'});
// 用了 http://fgnass.github.io/spin.js/ 来生成菊花
var spinnerOptions = {
lines: 13, // The number of lines to draw
length: 20, // The length of each line
width: 10, // The line thickness
radius: 30, // The radius of the inner circle
corners: 1, // Corner roundness (0..1)
rotate: 0, // The rotation offset
direction: 1, // 1: clockwise, -1: counterclockwise
color: '#000', // #rgb or #rrggbb or array of colors
speed: 1, // Rounds per second
trail: 60, // Afterglow percentage
shadow: false, // Whether to render a shadow
hwaccel: false, // Whether to use hardware acceleration
className: 'spinner', // The CSS class to assign to the spinner
zIndex: 2e9, // The z-index (defaults to 2000000000)
top: '50%', // Top position relative to parent
left: '50%' // Left position relative to parent
};
var _body = document.body;
var spinner = new Spinner(spinnerOptions).spin();
body.onloading = function () {
_body.appendChild(spinner.el);
};
body.onloaded = function () {
try {
_body.removeChild(spinner.el);
} catch (e) {
}
};
header.append(body);
9 个回复
DCloud_UNI_CHB
hello mui使用模板机制,会默认预加载几个页面,因此从chrome://inspect/#devices看webview的话,至少应该存在如下几个webview:
list.html
index-menu.html
template.html
template_pullrefresh.html
pullrefresh.html
参考:http://ask.dcloud.net.cn/article/106
scarlex (作者)
@DCloud_MUI_CHB
不是hello-mui,而是我自己写的 app,没做过任何预加载之类的。
假设我有一个页面是双webview模式来实现上下拉刷新的,叫 test-header.html 和 test-body.html。
我在另一个页面 (aaa.html) 中打开 test-header.html 时,这个 test-header.html 里面会把 test-body 这个 webview append 到 test-header 这个webview 中形成双 webview。
当我点后退的时候,这两个webview都没有关闭,只是隐藏了。然后我再进入这个页面,又会新建多两个 webview,再后退再进入,又多两个新的 webview。这样重复多几遍,chrome://inspect/#devices 里面看到的就是 2 x N + 1个 webview,那 1 个 webview 是 aaa.html。
mui 升级前没遇到过这个情况,每次点后退都是正常关闭掉 webview 的,升级后就多出了好多个 webview 出来。
DCloud_UNI_CHB
贴一下如下两处代码:
test-header.html append test-body的代码
scarlex (作者)
@DCloud_MUI_CHB
aaa.html 打开 test-header 的代码:
test-header append test-body 的代码:
DCloud_UNI_FXY
系统的后退键有没有问题?
scarlex (作者)
@DCloud_MUI_FXY
点两下系统的后退键就直接退出应用了
DCloud_UNI_FXY
你自己没额外处理后退的逻辑把。如果没有的话。可以发一个测试工程给我
scarlex (作者)
@DCloud_MUI_FXY
额外设置逻辑不是直接覆盖 mui.back 么?
我有试过覆盖它的
不过这样也是按两次系统的后退键就会退出应用,难道设置不对?
DCloud_UNI_FXY
把你自己处理的back都去掉。再测试