From 32a3177738b4eb22a39f8d22a497330cdda9aebe Mon Sep 17 00:00:00 2001 From: Alex <115539090+Alex-Programer@users.noreply.github.com> Date: Fri, 18 Nov 2022 13:29:59 +0800 Subject: [PATCH] doc: update vue.md (#126) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 和[Attribute 绑定]的部分重叠了 * doc: 新增自定义指令 * doc: 新增[响应式样式] * docs: [入门]部分改为vue3写法 * docs: 新增获取事件对象相关内容 * fix: 删除多余文件 * docs: 新增[组件通信]相关内容 --- docs/vue.md | 236 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 136 insertions(+), 100 deletions(-) diff --git a/docs/vue.md b/docs/vue.md index 5f9c996..c113341 100644 --- a/docs/vue.md +++ b/docs/vue.md @@ -64,13 +64,11 @@ $ npm run build ```js -import { createApp, ref } from 'vue' +import { createApp } from 'vue' const app = createApp({ - setup() { - const count = ref(0) - - return { count } + data() { + return { count: 0 } } }) app.mount('#app') @@ -92,18 +90,15 @@ app.mount('#app')
{{ message }}
- ``` @@ -112,13 +107,11 @@ app.mount('#app') ```html
{{ message }}
- - -``` - -### 传参的同时获取事件对象 - - -```html - - - -``` ### 动态参数 @@ -299,32 +270,6 @@ v-on:submit.prevent="onSubmit" ╰─ Name 以 v- 开头使用速记时可以省略 ``` -### 指令 Directives - -```html -

Now you see me

-``` - -### 自定义指令 Directives - - -```html - - - -``` - - -更多[指令函数参考](https://vuejs.org/guide/reusability/custom-directives.html) - 响应式基础 --- @@ -477,28 +422,6 @@ export default defineComponent({ }); ``` -### 响应式样式 - -```js - - - - - -``` - 响应式进阶 —— wath和computed --- @@ -558,6 +481,119 @@ const capital = computed(function(){

to capital: {{ capital }}

``` + +组件通信 +--- + +### defineProps + +```js + + + +``` + +子组件定义需要的参数 + +```js + + + +``` + +父组件参入参数 + +### defineEmits + +```js + + + +``` + +子组件定义支持 `emit` 的函数 + +```js + + + +``` + +父组件绑定子组件定义的事件 + +### defineExpose + +```js + + + +``` + +子组件对父组件暴露方法 + +```js + + + +``` + +父组件调用子组件的方法 + API 参考