> For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt.

# Lynx 3.4: HarmonyOS 支持，Trace 和 Recorder，文本输入元件

[← 所有文章](/next/zh/blog/)

2025年9月3日

![刘继龙](https://github.com/loongliu.png)刘继龙性能主管 @ Lynx![Lynx 团队](https://github.com/lynx-family.png)Lynx 团队lynxjs.org

Lynx 3.4 已经正式发布!

延续今年初公布的[技术路线图](/next/zh/blog/lynx-open-source-roadmap-2025.md)，我们一直保持着稳定的双月发布节奏。Lynx 3.3 版本因用户侧新功能较少而未单独发布博客，但该版本为 3.4 版本奠定了坚实基础。
Lynx 3.4 新增对 HarmonyOS 的适配支持、支持 Windows 作为 Lynx 开发环境、推出 _Trace_ 与 _Recorder_ 开发者工具、开源备受期待的原生组件 `<input>` 和 `<textarea>`，还带来了更灵活的动画效果、可变字体等功能。

## 新系统支持

### HarmonyOS 支持

Lynx 现已正式支持 [HarmonyOS](https://www.harmonyos.com/) 平台。开发者可参考 [接入现有应用](/next/zh/guide/start/integrate-with-existing-apps.md?platform=harmony)，将 Lynx 集成进 HarmonyOS 应用中。我们也将很快发布技术博客，深入介绍 Lynx 在 HarmonyOS 上的实现与优化，敬请期待。

![](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/lynx-website/assets/blog/lynx-harmony/background.png)

### Windows 开发环境支持

- 构建工具 [Rspeedy](/next/zh/guide/build/rspeedy.md) 现已支持 Windows 平台，开发者可在 Windows PC 上完成 Lynx 项目的开发与构建；

- 开发者可在 Windows 环境下成功编译安卓端的 Lynx Engine 及 [LynxExplorer](/next/zh/guide/start/quick-start.md#准备-lynx-explorer) 应用；

Devtool 桌面版对 Windows 的支持也在积极开发中，即将与大家见面。

## 新开发者工具

Lynx 3.4 引入了两款开发者工具，致力于提升开发者体验与调试效率。

### Trace

[Trace](/next/zh/guide/devtool/trace.md) 提供了全链路的渲染追踪与可视化能力，能够完整记录并展示 Lynx 页面从解析、构建、布局到渲染的全过程，同时深入监控引擎内部的执行逻辑。它将系统内部的工作状态由“黑盒”转变为清晰的可视化数据，有效帮助开发者理解底层运行机制，并显著提升定位与优化性能瓶颈的效率。

![](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/plugin/static/trace-tool-overview-latest2.png)

### Recorder

[Recorder](/next/zh/guide/devtool/recorder.md) 录制了 Lynx 应用运行时的一切外部依赖操作，包括资源加载、原生模块调用返回结果及用户交互事件流。录制内容可导出为文件，并可在 LynxExplorer 中精准回放，从而实现了复杂场景的“录屏式”调试，极大提升了难以复现的交互或异步问题的排查效率。

![](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/plugin/static/recorder-concept.png)

## 文本输入元件

在 Lynx 社区发起的 UI 能力[调研](https://github.com/lynx-family/lynx/discussions/673)中，`<input>`/`<textarea>` 以超过 50% 的得票率，成为开发者们最迫切期待的核心功能。
Lynx 3.4 交付了两个核心文本输入组件。我们将继续完善核心元件，欢迎开发者们在 [discussion](https://github.com/lynx-family/lynx/discussions/673) 中投票，共同定义 Lynx 的未来。

### 单行文本输入元件 [`<input>`](/next/zh/api/elements/built-in/input.md) \{#单行文本输入元件-input}

**下面是一个示例: input**

**Bundle:** `dist/autoHeight.lynx.bundle`

```tsx {13-20}
// Copyright 2024 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { root, useState } from "@lynx-js/react";

const App = () => {
  const [inputContent, setInputContent] = useState("");

  return (
    <view style={{ linearOrientation: "vertical", width: "100%", height: "100%", padding: "10px" }}>
      <view style={{ width: "100%", padding: "10px", backgroundColor: "#12345678", borderRadius: "10px" }}>
        <input
          style={{ width: "100%", color: "blue", fontSize: "30px" }}
          placeholder="search"
          bindinput={(res: any) => {
            console.log(res.detail.value);
            setInputContent(res.detail.value);
          }}
        />
      </view>
      <scroll-view
        scroll-orientation="vertical"
        list-type="single"
        span-count={1}
        style={{
          width: "100%",
          height: "100%",
        }}
      >
        {Array.from({ length: 50 }).map((item, index) => {
          return (
            <text style={{ fontSize: "20px", color: "gray", padding: "10px" }}>
              {`item-${index}${inputContent ? `-${inputContent}` : ""}`}
            </text>
          );
        })}
      </scroll-view>
    </view>
  );
};

root.render(<App />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```

v0.7.0



### 多行文本输入元件 [`<textarea>`](/next/zh/api/elements/built-in/textarea.md) \{#多行文本输入元件-textarea}

**下面是一个示例: textarea**

**Bundle:** `dist/base.lynx.bundle` | Web: `dist/base.web.bundle`

```tsx {13-21}
// Copyright 2024 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { root, useState } from "@lynx-js/react";

const App = () => {
  const [inputContent, setInputContent] = useState("");

  return (
    <view style={{ linearOrientation: "vertical", width: "100%", height: "100%", padding: "20px" }}>
      <view style={{ width: "100%", padding: "10px", backgroundColor: "#87654321", borderRadius: "10px" }}>
        <textarea
          style={{ width: "100%", color: "blue", fontSize: "50px" }}
          placeholder="Title"
          maxlines={2}
          bindinput={(res: any) => {
            console.log(res.detail.value);
            setInputContent(res.detail.value);
          }}
        />
      </view>

      <view
        style={{
          width: "100%",
          padding: "10px",
          marginTop: "20px",
          backgroundColor: "#12345678",
          borderRadius: "10px",
        }}
      >
        {
          <textarea
            style={{ width: "100%", height: "300px", fontSize: "30px" }}
            placeholder="Content"
            bindinput={(res: any) => {
              console.log(res.detail.value);
              setInputContent(res.detail.value);
            }}
          />
        }
      </view>
    </view>
  );
};

root.render(<App />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```

v0.7.0



## 更高自由度的`<list>`回收策略

### 回收 sticky 节点

当 `<list-item>` 被滚动出 `<list>` 视口时，原有回收机制会缓存该条目以供复用。在 Lynx 3.4 之前，具有 sticky 属性的 `<list-item>` 并不会被回收。在大量使用 sticky 特性的长列表中，这可能导致内存占用过高。Lynx 3.4 优化了这一策略，sticky 项在滚出视口后同样会被回收。
若该改动对你现有场景造成影响，可通过设置 [`experimental-recycle-sticky-item={false}`](/next/zh/api/elements/built-in/list.md#experimental-recycle-sticky-item) 暂时禁用此优化。如遇到任何问题，欢迎通过 issue 反馈。

| ![](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/plugin/static/not-recycle-sticky-1.gif) | ![](https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/plugin/static/recycle-sticky-1.gif) |

| sticky `<list-item>` in Lynx 3.3 | sticky `<list-item>` in Lynx 3.4 |


### 不回收 `<list-item>`

当 `<list-item>` 内含复杂元件时，回收并重新更新节点带来较高的 CPU 开销。开发者现可设置 `recyclable={false}` 来实现[特定 `<list-item>` 不回收](/next/zh/api/elements/built-in/list.md#实现-list-item-不回收)。禁用后，该条目滑出视窗后不会被回收，再次出现时也无需重新渲染，适用于对渲染性能有极致要求的场景。

**下面是一个示例: list**

**Entry:** `src/recyclable`
**Bundle:** `dist/recyclable.lynx.bundle` | Web: `dist/recyclable.web.bundle`

```tsx
// Copyright 2024 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

import { root } from "@lynx-js/react";
import "./index.scss";

const ListContainer = () => {
  return (
    <list
      className="list-container"
      scroll-orientation="vertical"
      list-type="flow"
      span-count={2}
    >
      <list-item
        item-key="list-item-over-flow"
        key="list-item-over-flow"
        style={{
          overflow: "visible",
          height: "40px",
          width: "100%",
        }}
        full-span={true}
        recyclable={false}
      >
        <view
          style={{
            height: "600px",
            backgroundImage: "linear-gradient(to bottom, rgba(255, 255, 0, 0.5), rgb(255, 255, 255, 0))",
          }}
        >
          <text style={{ fontSize: "15px" }}>
            {`The list item with overflow background color and recyclable: false`}
          </text>
        </view>
      </list-item>
      {Array.from({ length: 50 }).map((item, index) => {
        return (
          <list-item
            item-key={`list-item-${index + 1}`}
            key={`list-item-${index + 1}`}
            style={{
              height: "160px",
            }}
          >
            <view
              style={{
                border: "1px solid black",
                height: "100%",
              }}
            >
              <text style={{ height: "100%", fontSize: "20px" }}>{`list-item-${index + 1}`}</text>
            </view>
          </list-item>
        );
      })}
    </list>
  );
};

root.render(<ListContainer />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```

v0.7.1



## 更灵活的动画

### `Element.animate()`

[`MainThread.Element`](/next/zh/api/lynx-api/main-thread/main-thread-element.md) 新增 `animate()`方法，用于在 MTS 精细控制 CSS 动画，包括播放、暂停、跳转等操作，让交互动画实现更加灵活。

**下面是一个示例: animation**

**Entry:** `src/animate_mt`
**Bundle:** `dist/animate_mt.lynx.bundle` | Web: `dist/animate_mt.web.bundle`

```tsx
import { root, useMainThreadRef } from "@lynx-js/react";
import { MainThread } from "@lynx-js/types";

import "./index.scss";

const AnimateAnimationExample = () => {
  return (
    <view style={{ width: "100%", height: "100%" }}>
      <text style={{ textAlign: "center", fontSize: "30px" }}>
        Click To Start Animation
      </text>
      <view
        className="box"
        flatten={false}
        main-thread:bindtap={(event) => {
          "main thread";
          const ani = event.currentTarget.animate(
            [
              {
                transform: "translate(0%, 0%) rotate(0deg)",
                "animation-timing-function": "linear",
              },
              {
                transform: "translate(200px, 0%) rotate(90deg)",
                "animation-timing-function": "cubic-bezier(.91,.03,.94,.11)",
              },
              {
                transform: "translate(200px, 100%) rotate(180deg)",
                "animation-timing-function": "linear",
              },
              {
                transform: "translate(0%, 100%) rotate(270deg)",
                "animation-timing-function": "cubic-bezier(.91,.03,.94,.11)",
              },
              {
                transform: "translate(0%, 0%) rotate(360deg)",
              },
            ],
            {
              name: "animation-1",
              duration: 5000,
              iterations: Infinity,
              easing: "linear",
            },
          );
        }}
      >
      </view>
    </view>
  );
};
root.render(<AnimateAnimationExample />);

if (import.meta.webpackHot) {
  import.meta.webpackHot.accept();
}

```

v0.7.0



### CSS 变量触发 transition

现支持通过 CSS 变量的变化触发 transition 动画，提升了过渡动画的灵活性与可维护性。在多主题设计中，开发者可将动画参数与主题变量关联。切换主题时，只需修改变量值而无需改动选择器逻辑，即可完成主题切换。

**下面是一个示例: animation**

**Entry:** `src/transition_variable`
**Bundle:** `dist/transition_variable.lynx.bundle` | Web: `dist/transition_variable.web.bundle`

```scss
.button_scene_bright {
  --bg-color: #f2f2f2;
  --color: #000000;
}

.button_scene_dark {
  --bg-color: #343a46;
  --color: #ffffff;
}

.button {
  background-color: var(--bg-color);
  transition: all 0.3s;
  width: 142px;
  height: 48px;
  border-radius: 25px;
  align-items: center;
  justify-content: center;
}

.txt {
  color: var(--color);
  transition: all 0.3s;
  font-size: 16px;
  font-weight: 700;
}

.container {
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
}

```

v0.7.0



## 可变字体

Lynx 3.4 新增了对可变字体的支持，开发者现在可以通过 `font-variation-settings` 和 `font-optical-sizing` 等底层 CSS 属性，对字体样式进行更精细的微调。
阅读[MDN](https://developer.mozilla.org/zh-CN/docs/Web/CSS/CSS_fonts/Variable_fonts_guide) 和 [web.dev](https://web.dev/articles/variable-fonts) 了解可变字体技术细节。

**下面是一个示例: text**

**Entry:** `src/variable_font`
**Bundle:** `dist/variable_font.lynx.bundle` | Web: `dist/variable_font.web.bundle`

```tsx
import { root } from "@lynx-js/react";
import "./index.scss";

const VariableFont = () => {
  const fontSamples = [
    {
      title: "Normal",
      description: "Default font style",
      className: "",
    },
    {
      title: "Variable Weight (wght)",
      description: "font-variation-settings: 'wght' 750",
      className: "font-variation-settings",
    },
    {
      title: "Old-style Figures (onum)",
      description: "font-feature-settings: 'onum'",
      className: "font-feature-settings",
    },
    {
      title: "Combined Usage",
      description: "Applying both 'wght' and 'onum' features",
      className: "font-feature-settings font-variation-settings",
    },
  ];

  return (
    <view
      style={{ padding: "16px", display: "flex", flexDirection: "column", gap: "16px", backgroundColor: "#f4f4f4" }}
    >
      {fontSamples.map((sample, index) => (
        <view key={index} style={{ backgroundColor: "white", padding: "16px", borderRadius: "8px" }}>
          <text style={{ fontSize: "18px", fontWeight: "bold", color: "#333" }}>
            {sample.title}
          </text>
          <text style={{ fontSize: "14px", color: "#666", marginTop: "4px", marginBottom: "12px" }}>
            {sample.description}
          </text>
          <text className={`variable-font-normal ${sample.className}`} style={{ fontSize: "32px" }}>
            1234567890
          </text>
        </view>
      ))}
    </view>
  );
};

root.render(<VariableFont />);

```

v0.7.1



## 升级指南

参照官网[接入 Lynx 到现有应用](/next/zh/guide/start/integrate-with-existing-apps.md)，更新 Lynx 以及 LynxService 依赖版本，完成 Lynx 3.4 版本升级。
