Skip to content

React 文档(vue版)

仲灏2023-09-17约 1 分钟

React 18 => Vue 3 (2023年7月4日)

依赖注入

Prop 逐级透传问题

vue: provide inject

react: context

  1. 创建 context
jsx
import { createContext } from 'react';

export const LevelContext = createContext(1);
  1. 使用 Context
jsx
import { useContext } from 'react';
import { LevelContext } from './LevelContext.js';
  1. 提供 context