Files
mintlify__docs/zh/folder/nested/deep-relative-test.mdx
locadex-agent[bot] 89a700081d docs(locadex): add translations (#2567)
Co-authored-by: locadex-agent[bot] <217277504+locadex-agent[bot]@users.noreply.github.com>
2026-01-06 16:42:55 -08:00

95 lines
2.0 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "深层相对代码片段测试"
description: "用于验证多层嵌套相对路径代码片段导入的隐藏测试页面"
---
<div id="deep-relative-snippets-test">
# 深层相对代码片段测试
</div>
此页面位于 `/folder/nested/deep-relative-test.mdx`,用于测试多级相对导入。
---
<div id="test-1-two-levels-up-snippets">
## 测试 1:上移两级目录(`../../snippets/`)
</div>
使用 `../../snippets/` 从 `/snippets/test-snippet-a.mdx` 中导入:
import TestSnippetA from "../../snippets/test-snippet-a.mdx";
<TestSnippetA />
***
<div id="test-2-two-levels-up-with-named-export">
## 测试 2:上两级目录并使用命名导出
</div>
从 `/snippets/test-snippet-b.mdx` 导入:
import TestSnippetB, { testVariable } from "../../snippets/test-snippet-b.mdx";
<TestSnippetB />
**导出变量的值:** {testVariable}
***
<div id="test-3-one-level-up">
## 测试 3:上一层目录(`../`)
</div>
从父目录中的 `/folder/local-snippet.mdx` 导入:
import LocalSnippet, { localMessage } from "../local-snippet.mdx";
<LocalSnippet />
**导出的变量值:** {localMessage}
***
<div id="test-4-same-directory-sibling">
## 测试 4:同一目录(`./`)
</div>
从同一目录下的 `/folder/nested/deep-snippet.mdx` 导入:
import DeepSnippet, { deepMessage } from "./deep-snippet.mdx";
<DeepSnippet />
**导出的变量值:** {deepMessage}
***
<div id="test-5-mixed-absolute-path-for-comparison">
## 测试 5:混合 - 绝对路径(用于对照)
</div>
使用绝对路径导入:
import IconsRequired from "/snippets/zh/icons-required.mdx";
<IconsRequired />
***
<div id="path-resolution-summary">
## 路径解析总结
</div>
在路径为 `/folder/nested/deep-relative-test.mdx` 的页面中:
| 相对路径 | 解析为 |
|---------------|-------------|
| `../../snippets/test-snippet-a.mdx` | `/snippets/test-snippet-a.mdx` |
| `../local-snippet.mdx` | `/folder/local-snippet.mdx` |
| `./deep-snippet.mdx` | `/folder/nested/deep-snippet.mdx` |