@element-plus-ui/pro-provider
v1.0.0
Published
@element-plus-ui/pro-provider
Downloads
9
Maintainers
Readme
📦 安装
$ npm install @element-plus-ui/pro-provider
$ yarn add @element-plus-ui/pro-provider
$ pnpm add @element-plus-ui/pro-provider
🔨 使用
祖先组件
<template>
<pro-provider :value="{id: '101', name: '李四', role: 'admin'}">
<my-component-a>
<my-component-b/>
</my-component-a>
</pro-provider>
</template>
<script setup lang="ts">
import ProProvider from "@element-plus-ui/pro-provider"
</script>
后代组件
<script setup lang="ts">
import { inject } from 'vue'
// 注入单个值
const userId = inject<string>('id')
// 注入整个值
const user = inject('provider-value', {})
</script>