Vue 3的一些操作

  1. setup中修改属性的值需要 target.value 去获取到值.
  2. inheritAttrs:false 取消默认绑定
  3. 使用 $attrs/context.attrs 可以获取所有属性
  4. 使用 v-bind=$attrs 批量绑定属性
  5. propsattrs 的区别
    1. props 要先声明才能取值,attrs 不用先声明
    2. props 不包含时间,attrs包含
    3. props 没有声明的属性,会转移到attrs里面
    4. props 支持 string 类型以外的类型,attrs 只有个string类型
  6. 钩子函数的变更
    1. Vue2.X: beforeCreate->created->beforeMount->mounted->beforeUpdate->updated->beforeDestroy->destroyed
    2. Vue3.X(options): beforeCreate->created->beforeMount->mounted->beforeUpdate->updated->beforeUnmount->unmounted
    3. Vue3.X(hook setup):onBeforeMount->onMounted->onBeforeUpdate->onUpdated->onBeforeUnmont->onUnmounted
    4. setup 围绕 beforeCreatecreated运行的,不需要显示的定义

ui 库的 css 注意事项

  1. 不使用scoped属性
    1. data-v-[hash] 中的 [hash] 每次运行会变
    2. 必须输出稳定不变的class选择器, 方便使用者覆盖
  2. 必须加前缀
    1. 避免被误覆盖

__END__

o0Chivas0o
文章作者:o0Chivas0o
文章出处Vue 3
作者签名:Rich ? DoSomethingLike() : DoSomethingNeed()
版权声明:文章除特别声明外,均采用 BY-NC-SA 许可协议,转载请注明出处