100201组件拆分_编辑器-react-仿低代码平台项目

文章目录

    • [1 设计UI,组件拆分](#1 设计UI,组件拆分)
    • [2 实现](#2 实现)
    • 关于

1 设计UI,组件拆分

编辑器整体如上图所示,重点关注

  • flex弹性布局
  • 画布居中
  • 画布Y轴滚动

2 实现

src/pages/question/Edit/index.tsx代码如下:

ts 复制代码
import { FC } from "react";
import useLoadQuestionData from "@/hooks/useLoadQuestionData";

import styles from "./index.module.scss";

const Edit: FC = () => {
  // 获取问卷信息
  const { loading } = useLoadQuestionData();

  return (
    <div className={styles.container}>
      <div style={{ backgroundColor: "#fff", height: "40px" }}>Header</div>
      <div className={styles["content-wrapper"]}>
        <div className={styles.content}>
          <div className={styles.left}>Left</div>
          <div className={styles.main}>
            <div className={styles["canvas-wrapper"]}>
            
            </div>
          </div>
          <div className={styles.right}>Right</div>
        </div>
      </div>
    </div>
  );
};

export default Edit;

src/pages/question/Edit/index.module.scss代码如下:

scss 复制代码
.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: #f0f2f5;
}

.content-wrapper {
  flex: auto;
  padding: 12px 0;
}

.content {
  display: flex;
  margin: 0 24px;
  height: 100%;

  .left {
    width: 285px;
    background-color: #fff;
    padding: 0 12px;
  }

  .main {
    flex: 1;
    position: relative;
    overflow: hidden;

    .canvas-wrapper {
      position: absolute;
      width: 400px;
      height: 712px;
      top: 50%;
      left: 50%;
      transform: translateX(-50%) translateY(-50%);
      overflow: auto;
      box-shadow: 0 2px 10px #00001f;
    }
  }

  .right {
    width: 300px;
    background-color: #fff;
    padding: 0 12px;
  }
}

效果如下图所示:

关于

❓QQ:806797785

⭐️仓库地址:https://gitee.com/gaogzhen

⭐️仓库地址:https://github.com/gaogzhen

1\][react官网](https://reactjs.org/)\[CP/OL\]. \[2\][Redux官网](https://redux.js.org/)\[CP/OL\].

相关推荐
小奶包他干奶奶1 小时前
Webpack学习——Loader(文件转换器)
前端·学习·webpack
zy happy2 小时前
若依 vue3 报错:找不到模块“@/api/xxxx/xxxxx”或其相应的类型声明。。Vue 3 can not find mod
前端·javascript·vue.js
潘小安2 小时前
Git Worktree + Claude Code:让你的开发效率翻倍的秘密武器
前端
meichaoWen2 小时前
【Vue3】vue3的全面学习(一)
前端·javascript·学习
小猪努力学前端3 小时前
在 React + React Router v7 SSR 项目里做多端适配,我踩的两个坑
前端·react.js
weixin79893765432...3 小时前
Electron + React + Vite 实践
react.js·electron·vite
q***d1733 小时前
React桌面应用开发
前端·react.js·前端框架
8***29313 小时前
解决 Tomcat 跨域问题 - Tomcat 配置静态文件和 Java Web 服务(Spring MVC Springboot)同时允许跨域
java·前端·spring
0***143 小时前
React计算机视觉应用
前端·react.js·计算机视觉
Q***K553 小时前
React高级
前端·react.js·前端框架