From f0b8403a4d813baa519c07d7175f39b78fda7829 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?qz=E5=BD=B1=E6=9C=88?=
<14800590+qz-shadow-moon@user.noreply.gitee.com>
Date: Wed, 4 Jun 2025 09:09:24 +0000
Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: qz影月 <14800590+qz-shadow-moon@user.noreply.gitee.com>
---
qianzhen.html | 500 ++++++++++++++++++++++++++++++++++++++++++++++++++
qianzhen.js | 112 +++++++++++
2 files changed, 612 insertions(+)
create mode 100644 qianzhen.html
create mode 100644 qianzhen.js
diff --git a/qianzhen.html b/qianzhen.html
new file mode 100644
index 0000000..232f979
--- /dev/null
+++ b/qianzhen.html
@@ -0,0 +1,500 @@
+
+
+
+
+
+
+ 原生JS轮播图
+
+
+
+
+
+
原生JS轮播图
+
纯JavaScript实现,无任何框架依赖
+
+
+
+
+
+
+
+
❮
+
❯
+
+
+
+
+
+
+
+
+
+
+
+
+
+
🔄
+
无限轮播
+
首尾无缝衔接,循环播放不停歇
+
+
+
⏱️
+
自动播放
+
智能计时器自动切换,可随时暂停
+
+
+
↔️
+
箭头控制
+
左右箭头实现精确的手动控制
+
+
+
⭕
+
圆点导航
+
点击圆点可快速跳转到指定图片
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/qianzhen.js b/qianzhen.js
new file mode 100644
index 0000000..055c8a4
--- /dev/null
+++ b/qianzhen.js
@@ -0,0 +1,112 @@
+const cityData = [
+ {
+ parentValue: 1,
+ value: 11,
+ label: '北京市',
+ },
+ {
+ parentValue: 11,
+ value: 111,
+ label: '东城区'
+ },
+ {
+ parentValue: 11,
+ value: 112,
+ label: '西城区'
+ },
+ {
+ parentValue: 1,
+ value: 12,
+ label: '上海市',
+ },
+ {
+ parentValue: 12,
+ value: 121,
+ label: '黄浦区'
+ },
+ {
+ parentValue: 12,
+ value: 122,
+ label: '徐汇区'
+ },
+ {
+ parentValue: 1,
+ value: 13,
+ label: '广东省',
+ },
+ {
+ parentValue: 13,
+ value: 131,
+ label: '广州市',
+ },
+ {
+ parentValue: 131,
+ value: 1311,
+ label: '天河区'
+ },
+ {
+ parentValue: 131,
+ value: 1312,
+ label: '越秀区'
+ },
+ {
+ parentValue: 132,
+ value: 1321,
+ label: '南山区'
+ },
+ {
+ parentValue: 132,
+ value: 1322,
+ label: '罗湖区'
+ },
+ {
+ value: 1,
+ label: '中国',
+ },
+ {
+ parentValue: 13,
+ value: 132,
+ label: '深圳市',
+ }
+]
+
+
+const getArea = (data) => {
+ // 在这里编写代码
+ // 辅助函数:递归构建树节点
+ const buildTree = (parentId) => {
+ const children = [];
+ // 查找当前父节点的所有直接子节点
+ for (const item of data) {
+ if (item.parentValue === parentId) {
+ // 创建新节点(转换字段名)
+ const node = {
+ id: item.value,
+ title: item.label
+ };
+ // 递归构建子节点
+ const childNodes = buildTree(item.value);
+ if (childNodes.length > 0) {
+ node.child = childNodes;
+ }
+ children.push(node);
+ }
+ }
+ return children;
+ };
+
+ // 查找根节点(没有 parentValue 的节点)
+ const rootNode = data.find(item => item.parentValue === undefined);
+ if (rootNode) {
+ // 构建根节点
+ const root = {
+ id: rootNode.value,
+ title: rootNode.label,
+ child: buildTree(rootNode.value)
+ };
+ result.push(root);
+ }
+}
+const result = [];
+getArea(cityData);
+console.log(result);
--
Gitee