vue中attributes, methods ,events ,slots解释
学习vue,一定要对这四个名词理解分别是attribute, methods ,events ,slot咱们分别来介绍一下,都是我从网上找的,汇总起来方便自己查阅!
·
随便写写
attributes
html属性
<input type="textarea"></input>
type 就是属于attributes,html的属性,在vue中可以使用绑定 :type 来动态渲染html属性
slots
插槽,可以看一下官网,分为匿名插槽,具名插槽,作用域插槽
参考: https://cn.vuejs.org/v2/guide/components-slots.html
https://juejin.im/post/5a69ece0f265da3e5a5777ed
Events
自定义事件
<input @change="changeA"></input> 的@change
Methods
用户事件
感觉events 和 methods的区别就类似于 emit 和 on 的作用
更多推荐
已为社区贡献4条内容
所有评论(0)