1.学习vue知识点

92 阅读1分钟
  1. ajax、axios、fetch

  2. vue: $event

  3. vue: nextTick

  4. attrs-listeners

  • 从父组件传给自定义子组件的属性,如果有prop接收,就是prop属性,通过v-bind使用.如果没有prop接收会自动设置到子组件内部的最外层标签上,如果是class和style的话,会合并最外层标签的class和style.
  • 如果子组件中不想继承父组件传入的非prop属性,可以使用 inheriAttrs: false 禁用继承,然后通过v-bind="$attrs“把外部传入的非prop属性设置别希望的标签上,但是这不会包含class合style.
  • 父组件给子组件传递事件
<input type="text" v-bind="$attrs" @focus="$emit('focus', $event)" @input="$emit('input', $event)" />

//相当于下面

<input type="text" v-bind="$attrs" v-on="$listeners" />

attrs相当于展开父组件传递过来的属性给相应标签,listeners相当于展开父组件传递过来的原生dom事件