list的heigh究竟是否需要显示设置,很多场景下不设置就算内容超出了手机屏幕下方都不能拖动
感觉应该是list的高度解析的有问题,内容超过手机屏幕下方都不能拖动(有时候给repeat的数组多设置一些值,可能又能拖了)
我也遇到这个问题了,给list显示设置就可以拖动了,不过感觉显示设置是多余的。我这边还有一个问题想请教下,[h5-render] for scrollable root like 'list' and 'scroller', the height of the root container must be a user-specified value. Otherwise the scrollable element may not be able to work correctly. Current height of the root element '#weex' is 1739px, and mostly its height should be less than the viewport's height 1452px. Please make sure the height is correct.,控制台一直报这个警告,我已经在index.html里设置html,body,#weex{height:100%;width:100%;}了,不知道怎么还会报这个,也不知道1739这么大的值怎么计算出来的
实测
<template>
<list>
<cell>
<div style="background-color: red; height: 400;"></div>
</cell>
<cell>
<div style="background-color: blue; height: 400;"></div>
</cell>
<cell>
<div style="background-color: red; height: 400;"></div>
</cell>
<cell>
<div style="background-color: blue; height: 400;"></div>
</cell>
<cell>
<div style="background-color: red; height: 400;"></div>
</cell>
<cell>
<div style="background-color: blue; height: 400;"></div>
</cell>
<cell>
<div style="background-color: red; height: 400;"></div>
</cell>
</list>
</template>
这段代码在 iOS、Android 和 HTML5 版本下都是工作的
说一下我的使用场景: 我实在main.we里加载的lists.we,lists.we代码跟你的结构差不多,main.we的template如下
<template>
<div>
<header title="{{title}}"></header>
<lists></lists>
</div>
</template>
也就是说我在list外面包了一层就存在这个问题了
@YL2014 包在 dev 里的 list 组件已经不是 root 组件了。对于子的 list 组件,你可以通过 flex:1 设置其高度充满父元素。另外,如果是做为根节点的 div 组件,h5-render 不会自动设置其高度撑满 100%, 但是若果将根节点换成 list ,则会自动撑满,这就是根为 list 和根为 div 的区别。如果有页面滚动的需求,强烈建议使用 list / scroller 做为根节点。如果不是整页都要滚动,建议在代码里限制好根节点以及滚动节点的高度。
@squirrelx 你的问题是哪个平台的?android, ios还是h5?
@MrRaindrop android
@squirrelx 能给出一个完整的例子嘛?
@zshshr 我后面补充一下,现在手头没测试机
<template> <div style="width: 750;"> <div> <div style="height: 160; width: 750; background-color : red"> </div> <div style=""> <list > <cell> <div class="item {{selected == title ? 'item-selected' : ''}}" onclick="onclickitem" repeat={{items}}> <text class="item-title {{selected == title ? 'item-title-selected' : ''}}">{{title}}</text> </div> </cell> </list> </div> </div> </div> </template>
` `
@zshshr 代码贴上去了 样式有点问题 huawei mate7 android row15已结超过下边界了 但是不能拖动,如果你再增加两个row16和row17或者更多就能滑动了。。。
这个问题长时间没有讨论和反馈,如果有更多讨论仍然可以在这里继续,但这里会做close处理 谢谢
@Jinjiang 代码已经贴上去了啊 但是没有回应了
Sorry @zshshr 继续看一下吧,我 reopen
需要给list高度的
不设置高度的时候List确实会超出屏幕,不过官方demo里面在原生容器布局里面做了高度的限制 我截一段代码如下:
protected void renderPage(String template, String source, String jsonInitData) {
AssertUtil.throwIfNull(mContainer, new RuntimeException("Can't render page, container is null"));
Map<String, Object> options = new HashMap<>();
options.put(WXSDKInstance.BUNDLE_URL, source);
mInstance.render(
getPageName(),
template,
options,
jsonInitData,
ScreenUtil.getDisplayWidth(this), //屏幕宽度
ScreenUtil.getDisplayHeight(this), //屏幕高度
WXRenderStrategy.APPEND_ASYNC);
}
这样就限制了高度,list在放到容器中就不会超出屏幕的高度了
我贴的demo要如何做才能规避或者说避免这个问题呢? 能否有示例代码(或者我怎么样才能准确而又方便的计算出屏幕剩余高度,正好可以给list的高度赋值呢)
@squirrelx 刚才试过了,在nexus 5手机是正常工作,你用github上 android 分支的代码拉来试试,不确定你用的什么版本验证的
Done!
This PR/issue doesn't receive response since Weex migrated to Apache two years ago and this repository is no longer active yet.
Feel free to ask question in new repository and thanks for your contribution.
This issue is outdated for a long time. You can create a new one if you still have questions.