parent
05deb537f6
commit
7dbf5ed4d7
@ -0,0 +1,32 @@
|
||||
<script>
|
||||
import CN from '../index.zh-CN.md'
|
||||
import US from '../index.en-US.md'
|
||||
|
||||
const md = {
|
||||
cn: `# ConfigProvider 全局化配置
|
||||
为组件提供统一的全局化配置。`,
|
||||
us: `# ConfigProvider
|
||||
\`ConfigProvider\` provides a uniform configuration support for components.
|
||||
`,
|
||||
}
|
||||
export default {
|
||||
category: 'Components',
|
||||
subtitle: '全局化配置',
|
||||
cols: 1,
|
||||
type: '其他',
|
||||
title: 'ConfigProvider',
|
||||
render () {
|
||||
return (
|
||||
<div>
|
||||
<md cn={md.cn} us={md.us}/>
|
||||
<api>
|
||||
<template slot='cn'>
|
||||
<CN/>
|
||||
</template>
|
||||
<US/>
|
||||
</api>
|
||||
</div>
|
||||
)
|
||||
},
|
||||
}
|
||||
</script>
|
@ -0,0 +1,16 @@
|
||||
|
||||
## Usage
|
||||
|
||||
This component provides a configuration to all Vue components underneath itself via the [provide / inject](https://vuejs.org/v2/api/#provide-inject), In the render tree all components will have access to the provided config.
|
||||
|
||||
````html
|
||||
<a-config-provider :getPopupContainer="getPopupContainer">
|
||||
<app />
|
||||
</a-config-provider>
|
||||
````
|
||||
|
||||
## API
|
||||
|
||||
| Property | Description | Type | Default |
|
||||
| -------- | ----------- | ---- | ------- |
|
||||
| getPopupContainer | to set the container of the popup element. The default is to create a `div` element in `body`. | Function(triggerNode) | `() => document.body` |
|
@ -0,0 +1,25 @@
|
||||
|
||||
import PropTypes from '../_util/vue-types'
|
||||
|
||||
const ConfigProvider = {
|
||||
name: 'AConfigProvider',
|
||||
props: {
|
||||
getPopupContainer: PropTypes.func,
|
||||
},
|
||||
provide () {
|
||||
return {
|
||||
configProvider: this.$props,
|
||||
}
|
||||
},
|
||||
render () {
|
||||
return this.$slots.default ? this.$slots.default[0] : null
|
||||
},
|
||||
}
|
||||
|
||||
/* istanbul ignore next */
|
||||
ConfigProvider.install = function (Vue) {
|
||||
Vue.component(ConfigProvider.name, ConfigProvider)
|
||||
}
|
||||
|
||||
export default ConfigProvider
|
||||
|
@ -0,0 +1 @@
|
||||
import './index.less';
|
@ -0,0 +1,2 @@
|
||||
// placeholder
|
||||
@import '../../style/themes/default';
|
Loading…
Reference in new issue