【问题标题】:Mobile chrome browser doesn't display my div or results data移动 chrome 浏览器不显示我的 div 或结果数据
【发布时间】:2020-06-20 22:35:23
【问题描述】:

我的网站上有以下 React 代码,仅当搜索结果存在时才显示搜索结果 div。后端将搜索结果一次限制为 20 条,每条都是一个只有三个键值对的字典。

这适用于所有桌面浏览器以及 Android 上的 Firefox。但在 Android Chrome 上搜索结果永远不会显示。我尝试将显示更改为始终阻塞,让高度和宽度未定义,以及大量不同的格式更改。

是否存在与移动 Chrome 显示的 div 高度或数据相关的内容?有人遇到过吗?

<div
  style={{
    height: 150,
    width: "100%",
    overflowY: "scroll",
    display: this.props.hasSearchResults ? "" : "None"
  }}
>
  {/* switch to a div */}
  {/* <List> */}
  {this.props.search_results.map((result, idx) => (
    <div>
      <IconButton
        size="small"
        edge="end"
        onClick={event => {
          this.handleMenuAdd(event, result);
        }}
        style={{height: "100%"}}
      >
        <AddIcon
          style={{margin: "auto"}}
          fontSize="small"
        />
      </IconButton>
      <Typography
        style={{verticalAlign: "bottom"}}
        noWrap={true}
        // display="block"
        variant="caption"
      >
        {result.name}
      </Typography>
      <Typography
        variant="caption"
        style={{marginLeft: 10}}
        noWrap={true}
      >
        {result.item_type}
      </Typography>
    </div>
  ))}
</div>

【问题讨论】:

  • 您的问题更可能是 CSS 问题。尝试使用位置:修复。左上右下:0。z-index:1000000
  • 我会尝试让您知道。您是指外部 div 上的所有内容,对吗?
  • 不幸的是,这些(或全部)都没有解决这个问题。它在 Firefox 中可以正常工作,但一旦加载微调器在 Chrome 中停止,它就会消失。
  • 你能提供一个在线演示(jsfiddle/stackblitz/etc)吗?这样可以更容易为您提供帮助。
  • 你试过display: this.props.hasSearchResults ? "block" : "none" 吗?您还可以从桌面检查您的移动浏览器,看看发生了什么。它也可以是父元素样式。

标签: javascript css reactjs google-chrome


【解决方案1】:

感谢大家的关注和投入。问题出在服务器端。它根本没有小写搜索查询。在 Chrome 中,输入会自动大写,而在 Firefox 中则不会。感觉很傻,但会留在这里以防其他人需要看到它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-06
    • 1970-01-01
    • 2015-04-22
    • 2014-05-04
    • 2016-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多