legs+ 发表于 2025-7-5 17:08:49

精华来了:


legs+ 发表于 2025-7-6 22:08:20




闲来无事,用React的Router写了一个Demo


import React from "react";
import { BrowserRouter as Router, Routes, Route, Link } from "react-router-dom";

// 首页组件
function Home() {
return <h2 style={{ margin: 0 }}>首页</h2>;
}

// 关于我们组件
function About() {
return <h2 style={{ margin: 0 }}>关于我们</h2>;
}

// 主应用组件
function App() {
return (
    <div
      style={{
      minHeight: "100vh",
      display: "flex",
      flexDirection: "column",
      alignItems: "center",
      justifyContent: "center",
      background: "#f5f7fa",
      }}
    >
      <Router>
      <nav
          style={{
            marginBottom: "2rem",
            background: "#fff",
            padding: "12px 32px",
            borderRadius: "12px",
            boxShadow: "0 2px 12px rgba(0,0,0,0.08)",
            display: "flex",
            gap: "1.5rem",
            fontSize: "1.1rem",
            fontWeight: 500,
          }}
      >
          <Link to="/" style={{ textDecoration: "none", color: "#222" }}>
            首页
          </Link>
          <span style={{ color: "#ccc" }}>|</span>
          <Link to="/about" style={{ textDecoration: "none", color: "#222" }}>
            关于
          </Link>
      </nav>

      <div
          style={{
            background: "#fff",
            padding: "32px 48px",
            borderRadius: "16px",
            boxShadow: "0 4px 24px rgba(0,0,0,0.10)",
            minWidth: "260px",
            textAlign: "center",
          }}
      >
          <Routes>
            <Route path="/" element={<Home />} />
            <Route path="/about" element={<About />} />
          </Routes>
      </div>
      </Router>
    </div>
);
}

export default App;


legs+ 发表于 2025-7-8 17:47:01

今天,我在使用阿里的 Umi 框架的时候,突然发现一个问题

npm install umi --save-dev 中 save 和 dev 是什么意思

于是,我就问通义,得出的结论如下



很值得深思

一个是生产依赖,一个是开发依赖

结论,差之毫厘,谬以千里

很值得注意,这里留个爪

legs+ 发表于 2025-7-8 17:51:04

顺便,也问了一下 umi 框架的情况,及其与 react 的关系



legs+ 发表于 2025-7-10 07:27:25

今天,运行了一下阿里的umi(米)框架:





如果说react是一个JS 库,那么umi就是react framework


集成了路由、构建、部署、Mock、代理等一整套解决方案,支持现代 Web 开发所需的各种功能。
页: 1 2 [3]
查看完整版本: 今天用react写了一个小小的DEMO: