我正在尝试实现dojox.mobile.ContentPane来解析来自html的内容。但是,根本没有显示任何文字。这是我的html文件要解析为dojox.mobile.ContentPane(filename:fragment1.html):
<div data-dojo-type='dojox.mobile.RoundRect' shadow='true'>
HTML fragment example
</div>
这是我的index.html:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>dojox/mobile Demo</title>
<script src="http://ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js" data-dojo-config="async: true"></script>
<script type="text/javascript">
require(["dojox/mobile/parser", "dojox/mobile", "dojox/mobile/deviceTheme", "dojox/mobile/compat", "dojo/domReady!","dojox/mobile/ContentPane", "dojox/mobile/RoundRect", "dojox/mobile/RoundRectCategory"], function(parser) {
parser.parse();
});
</script>
</head>
<body>
<div id="main" data-dojo-type="dojox.mobile.View" data-dojo-props="selected: true">
<h1 data-dojo-type="dojox.mobile.Heading">Main Menu</h1>
<ul data-dojo-type="dojox.mobile.RoundRectList">
<li data-dojo-type="dojox.mobile.ListItem" data-dojo-props="moveTo: 'view-content'">
View Content
</li>
</div>
<div id="view-content" data-dojo-type="dojox.mobile.View">
<h1 data-dojo-type="dojox.mobile.Heading" data-dojo-props="back:'Main Menu', moveTo:'main'">This is sample content</h1>
<h2 data-dojo-type="dojox.mobile.RoundRectCategory">Pane1</h2>
<div id="pane1" data-dojo-type="dojox.mobile.ContentPane" content="<div data-dojo-type='dojox.mobile.RoundRect' shadow='true'>Thank you!</div>"></div>
<h2 data-dojo-type="dojox.mobile.RoundRectCategory">Pane2</h2>
<div id="pane2" data-dojo-type="dojox.mobile.ContentPane" href="fragment1.html"></div>
</div>
</body>
</html>
有人有解决方案吗? 感谢。
答案 0 :(得分:0)
您的片段与the documentation非常相似!我想这里发生的事情是你的parser.parse()
行可能过早执行;在ContentPane小部件提取外部HTML内容并将其插入DOM之前。您是否尝试使用调试器来查看加载时DOM中的实际内容?控制台里有什么?
无论如何,我认为您可能需要打开ContentPane上的parseOnLoad: true
属性(请参阅文档)。看起来会做你想做的事。