提交 f45f004b 编写于 作者: D dolymood

update(doc): popup create-api doc link

上级 91f1ee24
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
`ActionSheet` provides two common styles and it is flexible. `ActionSheet` provides two common styles and it is flexible.
__Notice:__ Cause this component used create-api, so you should read [create-api](#/en-US/docs/create-api) first.
### Example ### Example
- Basic usage - Basic usage
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
`CascadePicker` component is used to implement the cascading change between picker columns. What is the effect of cascade? Considering the usage of province-city-area picker, when the province is changed, you may want the city column to display the exact cities of current province, so does the area column. And the `CascadePicker` is here to help you handle this. `CascadePicker` component is used to implement the cascading change between picker columns. What is the effect of cascade? Considering the usage of province-city-area picker, when the province is changed, you may want the city column to display the exact cities of current province, so does the area column. And the `CascadePicker` is here to help you handle this.
__Notice:__ Cause this component used create-api, so you should read [create-api](#/en-US/docs/create-api) first.
### Example ### Example
- Basic usage - Basic usage
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
This module exports a function called `createAPI` with which you can invoke the custom component which has been instantiated in api form. This module exports a function called `createAPI` with which you can invoke the custom component which has been instantiated in api form.
__Notice:__ All componnets which used `createAPI` must be registered by `Vue.use`.
### createAPI(Vue, Component, [events, single]) ### createAPI(Vue, Component, [events, single])
- Parameters: - Parameters:
...@@ -17,7 +19,7 @@ This module exports a function called `createAPI` with which you can invoke the ...@@ -17,7 +19,7 @@ This module exports a function called `createAPI` with which you can invoke the
- `{Object} config` It will be passed to the component as its props except the events in `events`(It will transform by default, eg: If `events` has value `['click']`, then the prop `onClick` will be treated as component's event and not component's props). - `{Object} config` It will be passed to the component as its props except the events in `events`(It will transform by default, eg: If `events` has value `['click']`, then the prop `onClick` will be treated as component's event and not component's props).
- `{Function} [renderFn]` Optional, used to generate the VNode child node in the slot scene in general. - `{Function} [renderFn]` Optional, used to generate the VNode child node in the slot scene in general.
- `{Boolean} [single]` Optional, whether the instantiated component is a singleton or not. If two parameters are provided and the `renderFn`'s type is not function, then the `single` value is the sencond parameter's value. - `{Boolean} [single]` Optional, whether the instantiated component is a singleton or not. If two parameters are provided and the `renderFn`'s type is not function, then the `single` value is the sencond parameter's value.
- The return of the method `instance` is a instantiated Vue component,and the `remove` method will be **attached** to this instance.You can invoke the `remove` method to destroy the component and detach the component's content from `body` element. - The return of the method `instance` is a instantiated Vue component,and the `remove` method will be **attached** to this instance.You can invoke the `remove` method to destroy the component and detach the component's content from `body` element. If the caller is destroyed and the `instance` will be destroyed too.
- Example: - Example:
...@@ -115,18 +117,14 @@ This module exports a function called `createAPI` with which you can invoke the ...@@ -115,18 +117,14 @@ This module exports a function called `createAPI` with which you can invoke the
``` ```
In this example, we create a component `Hello` which needs to be invoked in api form and we invoke it in another component.The focus is what `showHello()` does: invoking method `this.$createHello(config, renderFn)` to instantiate `Hello`. In this example, we create a component `Hello` which needs to be invoked in api form and we invoke it in another component.The focus is what `showHello()` does: invoking method `this.$createHello(config, renderFn)` to instantiate `Hello`.
### How to use in general JS files ### How to use in general JS files or use it in global
In vue component, you could call by `this.$createHello(config, renderFn)` because the `this` is just a vue instance. But in general JS files, you need to call `$createHello` method by `Vue.prototype` or create a vue instance. As shown below: In vue component, you could call by `this.$createHello(config, renderFn)` because the `this` is just a vue instance. But in general JS files, you need to use `Hello.$create`. As shown below:
```js ```js
import Vue from 'vue' import Hello from './hello.vue'
Vue.prototype.$createHello(config, renderFn)
// or Hello.$create(config, renderFn)
const vm = new Vue()
vm.$createHello(config, renderFn)
``` ```
There is another idea which used the mode of data-driven. For example, in vuex, you could use a global state to label whether to call the component, and watch this state in App.vue to handle this component. There is another idea which used the mode of data-driven. For example, in vuex, you could use a global state to label whether to call the component, and watch this state in App.vue to handle this component.
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
`Dialog` modal component,provides various styles and interactions. `Dialog` modal component,provides various styles and interactions.
__Notice:__ Cause this component used create-api, so you should read [create-api](#/en-US/docs/create-api) first.
### Example ### Example
- Dialog type - Dialog type
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
`Picker` component supports multi-column selectors and linkage data. `Picker` component supports multi-column selectors and linkage data.
__Notice:__ Cause this component used create-api, so you should read [create-api](#/en-US/docs/create-api) first.
### Example ### Example
- Basic usage - Basic usage
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
The underlying popup component, mainly used to implement upper component encapsulation based on itself. It only provides basic functions: specifying the type, whether there's a background layer, showing content (HTML) and whether the component is in center position. The underlying popup component, mainly used to implement upper component encapsulation based on itself. It only provides basic functions: specifying the type, whether there's a background layer, showing content (HTML) and whether the component is in center position.
All of the built-in popup type components are implemented based on this component, including [Toast](#/en-US/docs/toast)[Picker](#/en-US/docs/picker)[TimePicker](#/en-US/docs/time-picker)[Dialog](#/en-US/docs/dialog)[ActionSheet](#/en-US/docs/action-sheet). Most of the built-in popup type components are implemented based on this component, including [Toast](#/en-US/docs/toast)[Picker](#/en-US/docs/picker)[CascadePicker](#/en-US/docs/cascade-picker)[DatePicker](#/en-US/docs/date-picker)[TimePicker](#/en-US/docs/time-picker)[SegmentPicker](#/en-US/docs/segment-picker)[Dialog](#/en-US/docs/dialog)[ActionSheet](#/en-US/docs/action-sheet).
__Notice:__ All the components above used create-api, so you should read [create-api](#/en-US/docs/create-api) first.
### Example ### Example
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
Select component. Select component.
__Notice:__ Cause this component depend on Picker component, and Picker used create-api, so you should read [create-api](#/en-US/docs/create-api) first.
### Example ### Example
- Basic usage - Basic usage
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
`TimePicker` component provides commonly used functions of date selection. `TimePicker` component provides commonly used functions of date selection.
__Notice:__ Cause this component used create-api, so you should read [create-api](#/en-US/docs/create-api) first.
### Example ### Example
- Basic usage - Basic usage
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
`Toast` component.You can use it to show non-modal tip message without user interaction. `Toast` component.You can use it to show non-modal tip message without user interaction.
__Notice:__ Cause this component used create-api, so you should read [create-api](#/en-US/docs/create-api) first.
### Example ### Example
- Duration of display - Duration of display
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
`ActionSheet`操作列表提供了两种常见的样式,灵活可控内容。 `ActionSheet`操作列表提供了两种常见的样式,灵活可控内容。
__注:__ 由于此组件基于 create-api 实现,所以在使用之前,请确保自己了解过 [create-api](#/zh-CN/docs/create-api)
### 示例 ### 示例
- 基本用法 - 基本用法
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
`CascadePicker`组件是级联选择器,用于实现多列选择之间的级联变化。比如,在选择省市区时,当省切换到了江苏省,城市列应该变成江苏省的各个城市,同理,如果城市切换到苏州市,区列的选项也应变成苏州市的各个区,这就级联的意义。 `CascadePicker`组件是级联选择器,用于实现多列选择之间的级联变化。比如,在选择省市区时,当省切换到了江苏省,城市列应该变成江苏省的各个城市,同理,如果城市切换到苏州市,区列的选项也应变成苏州市的各个区,这就级联的意义。
__注:__ 由于此组件基于 create-api 实现,所以在使用之前,请确保自己了解过 [create-api](#/zh-CN/docs/create-api)
### 示例 ### 示例
- 基本用法 - 基本用法
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
该模块默认暴露出一个 `createAPI` 函数,可以实现以 API 的形式调用自定义组件。 该模块默认暴露出一个 `createAPI` 函数,可以实现以 API 的形式调用自定义组件。
__注:__ 所有通过 `createAPI` 实现的通过 API 的形式调用的自定义组件都需要通过 `Vue.use` 注册才可以。
### createAPI(Vue, Component, [events, single]) ### createAPI(Vue, Component, [events, single])
- 参数: - 参数:
...@@ -17,7 +19,7 @@ ...@@ -17,7 +19,7 @@
- `{Object} config` 组件配置参数,默认所有的值都会当做 props 传给组件,但是要排除 `events` 中的事件(默认会做转换,例如:`events` 的值为 `['click']`,那么 `config` 中的 `onClick` 就是作为 `click` 事件的回调函数,而不是作为 props 传递给组件)。 - `{Object} config` 组件配置参数,默认所有的值都会当做 props 传给组件,但是要排除 `events` 中的事件(默认会做转换,例如:`events` 的值为 `['click']`,那么 `config` 中的 `onClick` 就是作为 `click` 事件的回调函数,而不是作为 props 传递给组件)。
- `{Function} [renderFn]` 可选参数,用于生成子 VNode 节点,一般场景是处理 slot。 - `{Function} [renderFn]` 可选参数,用于生成子 VNode 节点,一般场景是处理 slot。
- `{Boolean} [single]` 可选参数,创建的时候决定是否是单例的,优先级更高,如果没有传入 renderFn 的话,single 的值就是第二个参数的值。 - `{Boolean} [single]` 可选参数,创建的时候决定是否是单例的,优先级更高,如果没有传入 renderFn 的话,single 的值就是第二个参数的值。
- 注意调用后的返回值 `instance` 就是组件实例,这个实例会被**附加**或者**代理** `remove` 方法,如果调用了,该实例就会被销毁且会从 `body` 下移除。 - 注意调用后的返回值 `instance` 就是组件实例,这个实例会被**附加**或者**代理** `remove` 方法,如果调用了,该实例就会被销毁且会从 `body` 下移除。如果说实例化上下文(即 `this.$createXx` 中的 `this`)销毁的话会自动移除销毁该实例元素。
- 示例: - 示例:
...@@ -119,18 +121,14 @@ ...@@ -119,18 +121,14 @@
示例中就是创建了一个需要 API 调用的组件 `Hello`,然后在其他组件中去使用,重点就是 `showHello()` 方法做的事情:调用 `this.$createHello(config, renderFn)` 实现组件的实例化。 示例中就是创建了一个需要 API 调用的组件 `Hello`,然后在其他组件中去使用,重点就是 `showHello()` 方法做的事情:调用 `this.$createHello(config, renderFn)` 实现组件的实例化。
### 如何在普通 js 文件中调用 ### 如何在普通 js 文件中或者全局调用
一般当你在 vue 实例中,你可以直接通过 `this.$createHello(config, renderFn)` 调用该组件。而如果在普通 JS 中`this`不是 vue 实例,这时就需要通过`Vue.prototye`或者创建一个 vue 实例来调用`$createHello`方法了,比如: 一般当你在 Vue 实例中,你可以直接通过 `this.$createHello(config, renderFn)` 调用该组件。而如果在普通 JS 中`this`不是 vue 实例,这时就可以通过组件本身的 `$create` 来进行实例化了,比如:
```js ```js
import Vue from 'vue' import Hello from './hello.vue'
Vue.prototype.$createHello(config, renderFn)
// 或者 Hello.$create(config, renderFn)
const vm = new Vue()
vm.$createHello(config, renderFn)
``` ```
还有一种思路是通过数据驱动,比如用 vuex 维护一个全局 state,在需要调用该组件时更新状态,然后在 App.vue 里去 watch 这个状态变化来调用该组件。 还有一种思路是通过数据驱动,比如用 vuex 维护一个全局 state,在需要调用该组件时更新状态,然后在 App.vue 里去 watch 这个状态变化来调用该组件。
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
日期选择器,可用于日期选择,选择粒度的灵活配置,如年月日、时分秒、年月日时分秒、年月等。 日期选择器,可用于日期选择,选择粒度的灵活配置,如年月日、时分秒、年月日时分秒、年月等。
__注:__ 由于此组件基于 create-api 实现,所以在使用之前,请确保自己了解过 [create-api](#/zh-CN/docs/create-api)
### 示例 ### 示例
- 基本用法 - 基本用法
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
`Dialog`模态框组件,提供了多种样式及交互形式。 `Dialog`模态框组件,提供了多种样式及交互形式。
__注:__ 由于此组件基于 create-api 实现,所以在使用之前,请确保自己了解过 [create-api](#/zh-CN/docs/create-api)
### 示例 ### 示例
- 类型设置 - 类型设置
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
`Picker`组件支持多列选择器及数据联动。 `Picker`组件支持多列选择器及数据联动。
__注:__ 由于此组件基于 create-api 实现,所以在使用之前,请确保自己了解过 [create-api](#/zh-CN/docs/create-api)
### 示例 ### 示例
- 基本用法 - 基本用法
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
底层弹层组件,主要用于基于此组件实现上层组件封装,只提供了基础功能:指定类型、是否有背景层、显示内容(HTML)以及是否居中。 底层弹层组件,主要用于基于此组件实现上层组件封装,只提供了基础功能:指定类型、是否有背景层、显示内容(HTML)以及是否居中。
内置所有的弹层类组件都是基于此组件实现,包括:[Toast](#/zh-CN/docs/toast)[Picker](#/zh-CN/docs/picker)[TimePicker](#/zh-CN/docs/time-picker)[Dialog](#/zh-CN/docs/dialog)[ActionSheet](#/zh-CN/docs/action-sheet) 内置弹层类组件基本都是基于此组件实现,包括:[Toast](#/zh-CN/docs/toast)[Picker](#/zh-CN/docs/picker)[CascadePicker](#/zh-CN/docs/cascade-picker)[DatePicker](#/zh-CN/docs/date-picker)[TimePicker](#/zh-CN/docs/time-picker)[SegmentPicker](#/zh-CN/docs/segment-picker)[Dialog](#/zh-CN/docs/dialog)[ActionSheet](#/zh-CN/docs/action-sheet)
__注:__ 以上组件都是基于 create-api 实现,所以在使用之前,请确保自己了解过 [create-api](#/zh-CN/docs/create-api)
### 示例 ### 示例
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
Select 组件,用于单项选择。 Select 组件,用于单项选择。
__注:__ 由于此组件依赖 [Picker](#/zh-CN/docs/picker) 组件,而 Picker 组件是基于 create-api 实现,所以在使用之前,请确保自己了解过 [create-api](#/zh-CN/docs/create-api)
### 示例 ### 示例
- 基本用法 - 基本用法
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
`TimePicker`组件提供了常用的日期选择功能。 `TimePicker`组件提供了常用的日期选择功能。
__注:__ 由于此组件基于 create-api 实现,所以在使用之前,请确保自己了解过 [create-api](#/zh-CN/docs/create-api)
### 示例 ### 示例
- 基本用法 - 基本用法
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
`Toast`组件主要用于非模态信息提醒,无需用户交互。 `Toast`组件主要用于非模态信息提醒,无需用户交互。
__注:__ 由于此组件基于 create-api 实现,所以在使用之前,请确保自己了解过 [create-api](#/zh-CN/docs/create-api)
### 示例 ### 示例
- 显示时间设置 - 显示时间设置
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册