Index页面的JavaScript:
<script type="text/javascript" charset="utf-8">
mui.init();
var page = null;
mui.plusReady(function() {
mui('.mui-content').on('tap', 'a', function() {
var id = this.getAttribute('id');
var Ititle = this.getAttribute('data-title');
// 获取详情页面
page = plus.webview.getWebviewById('news.html');
// 触发news.html的newid事件
mui.fire(page, 'newid', {
id: id,
Ititle: Ititle
});
mui.openWindow({
url: 'news.html'
});
});
});
mui.ready(function() {
// 放到mui.ready里,可以防止出现.addEventListener of null的报错问题
document.getElementById("home").addEventListener('tap', function() {
// 打开main.html页面
mui.openWindow({
url: 'feedback.html',
//id: 'feedback.html'
});
});
});
</script>
news页面的JavaScript代码:
<script type="text/javascript">
mui.init();
var id = null;
var title = null;
mui.ready(function(){
mui.toast('gweagw');
window.addEventListener('newid',function(){
//获取列表页的a标签的id值
id = event.page.id;
title = event.page.Ititle;
values = id + " , " + title;
mui.toast('gweagw' + values);
document.getElementById("Ititle").innerText = title;
document.getElementById("Ibody").innerHTML = id;
});
});
</script>
index页面通过mui.fire函数将值传到news页面,news页面没有触发addEventListener,因为toast打印不出来东西啊!!
为什么没有触发这个函数?求解,官方能给一份完整点的文档吗?很多代码都是一小段看着莫名其妙呢