mui loadUrl错误?
错误:
Uncaught TypeError: Cannot read property 'loadURL' of undefined
js及html源码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<title></title>
<script src="js/mui.min.js"></script>
<script src="js/util/backToKillApp.js"></script>
<script src="js/lib/angular/angular.min.js"></script>
<script src="js/common.js"></script>
<link href="css/mui.min.css" rel="stylesheet"/>
</head>
<body ng-app="ap" ng-controller="ctl">
<header class="mui-bar mui-bar-nav">
<h1 class="mui-title">H5App</h1>
</header>
<nav class="mui-bar mui-bar-tab">
<a class="mui-tab-item mui-active" id="home">
<span class="mui-icon mui-icon-home"></span>
<span class="mui-tab-label">首页</span>
</a>
<a class="mui-tab-item" id="account">
<span class="mui-icon mui-icon-person"></span>
<span class="mui-tab-label">账户</span>
</a>
<a class="mui-tab-item" id="cart">
<span class="mui-icon mui-icon-more"></span>
<span class="mui-badge mui-badge-red">{{orderCount}}</span>
<span class="mui-tab-label">购物车</span>
</a>
</nav>
</body>
<script type="text/javascript" charset="utf-8">
angular.module('ap',[])
.controller('ctl', function($scope){
$scope.orderCount=4;
function selfAdd() {
$scope.orderCount = $scope.orderCount + 1;
$scope.$apply();
}
setInterval(selfAdd, 4000);
});
var homeUrl = "pages/home.html";
var accountUrl= "pages/account.html";
var cartUrl = "pages/cart.html";
var contentView;
var contentStyles = {top: '9%', bottom: '10%'};
mui.init();
document.addEventListener('plusready',plusReady,false);
function plusReady () {
contentView = plus.webview.create(homeUrl,'contentView',contentStyles);
contentView.addEventListener('close', closeApp);
contentView.show();
}
</script>
<script type="text/javascript" charset="utf-8">
var detailPage = null;
document.getElementById('home').addEventListener('tap',function(){
// contentView.loadURL(homeUrl);
var id = this.getAttribute('id');
//获得详情页面
if(!detailPage){
detailPage = plus.webview.getWebviewById('detail.html');
}
alert(1);
//触发详情页面的newsId事件
mui.fire(detailPage,'newsId',{
id:id
});
//打开详情页面 www.bcty365.com
mui.openWindow({
id:'detail.html'
});
});
document.getElementById('cart').addEventListener('tap',function(){
contentView.loadURL(cartUrl);
});
document.getElementById('account').addEventListener('tap',function(){
contentView.loadURL(accountUrl);
});
</script>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论