Javascript 如何将dojox.mobile.View设置为高度100%
是否可以将dojox.mobile.View设置为100%高度 例如: 改为使用dojox.mobile.ScrollableView。但是我的目的是在视图上添加一个触摸事件,因此视图不需要滚动Javascript 如何将dojox.mobile.View设置为高度100%,javascript,mobile,dojo,dojox.mobile,Javascript,Mobile,Dojo,Dojox.mobile,是否可以将dojox.mobile.View设置为100%高度 例如: 改为使用dojox.mobile.ScrollableView。但是我的目的是在视图上添加一个触摸事件,因此视图不需要滚动 非常感谢。我在网页设计方面不是很有天赋,但我及时了解到100%的身高总是会带来麻烦。相反,我将以像素为单位获取文档高度,并从中减去标题、菜单等。然后以像素为单位给出绝对高度。我知道这很旧,但我就是这样做的。我使用了mbecker提到的内容,创建了一个扩展常规视图的新视图: define([ "d
非常感谢。我在网页设计方面不是很有天赋,但我及时了解到100%的身高总是会带来麻烦。相反,我将以像素为单位获取文档高度,并从中减去标题、菜单等。然后以像素为单位给出绝对高度。我知道这很旧,但我就是这样做的。我使用了mbecker提到的内容,创建了一个扩展常规视图的新视图:
define([
"dojo/_base/declare",
"dojo/dom",
"dojo/dom-geometry",
"dojo/dom-style",
"dojo/window",
"dojox/mobile/View",
], function( declare,dom,domGeometry, domStyle, win,View){
// module:
// custom/widget/View2
console.log("Loading View2");
return declare("custom.widget.View2", [View], {
tabName:"outertabbar",
resize: function(){
//this is for a fixed tabbar
//if you dont have one remove this and the tabbox
var tabBar = dom.byId(this.tabName);
var tabBox = domGeometry.getMarginBox(tabBar);
var winBox = win.getBox();
var height=winBox.h - tabBox.h + "px";
domStyle.set(this.domNode, "height",height);
// summary:
// Calls resize() of each child widget.
this.inherited(arguments); // scrollable#resize() will be called
}
});
});
我和ContentPaneResizeMixin玩过,但最终还是决定了这一点。不要期望直接复制和粘贴,但这种模式会起作用。在这里,我在头文件的dojoConfig中设置了服务器的has变量。我检测桌面(通过phpMobileDetect)
以编程方式设置高度没有问题,但我更喜欢css解决方案:
<script src="/dojo/dojo.js" type="text/javascript" data-dojo-config="parseOnLoad: false, async: 1, isDebug: 1, mblAlwaysHideAddressBar: false, has: { 'isDesktop': <?= json_encode($isDesktop) ?> }"></script>
define([
"dojo/_base/declare",
"dojo/_base/lang",
"dojo/has",
"dojo/has!isDesktop?dojox/mobile/Pane:dojox/mobile/ScrollablePane"
], function(declare, lang, has, Pane) {
return declare("tt.app.ScrollableAwarePane", [ Pane ], {
resize: function(){
this.inherited(arguments);
if(has('isDesktop')){
this.containerNode.style.overflowY = "scroll";
var height = rightPane.offsetHeight - this.getPreviousSibling().domNode.offsetHeight;
this.containerNode.style.height = height + "px";
}
}
});
});