2019-08-29 - Vue - 随笔

自定义事件

.sync 修饰符

父组件:

写法:

1. 

2. 

子组件:

    this.$emit('update:title', newTitle)

插槽

父组件:

写法:

跟 v-on (@)和 v-bind(:) 一样,v-slot 也有缩写,即把参数之前的所有内容 (v-slot:) 替换为字符 (#)。例如 v-slot:header 可以被重写为 #header:

1.  

2. 

3.    //废弃了的语法

 

 //

 

子组件:

 

 

 

注意 v-slot 只能添加在一个