
正文
vue的slot的使用问题
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
slot的使用问题根据官方文档来说,有三种使用方式https://cn.vuejs.org/v2/guide/components.html#%E4%BD%BF%E7%94%A8%E6%8F%92%E6%A7%BD%E5%88%86%E5%8F%91%E5%86%85%E5%AE%B9
- 单个插槽 https://github.com/Sinosaurus/blogs/blob/master/example/slot01.html
- 具名插槽 https://github.com/Sinosaurus/blogs/blob/master/example/slot02.html
作用域插槽 https://github.com/Sinosaurus/blogs/blob/master/example/slot-scope.html
总结:- 可以利用作用域插槽 进行子向父传值,但是有限制,只能在子组件中使用而已(暂时这么理解)
vue2.5以上可以不适用template进行也可以正常使用slot-scopeslot-scope可以分开,slot写具名插槽,scope写传过来的参数
https://cn.vuejs.org/v2/guide/components.html#%E4%BD%BF%E7%94%A8%E6%8F%92%E6%A7%BD%E5%88%86%E5%8F%91%E5%86%85%E5%AE%B9
- 单个插槽 https://github.com/Sinosaurus/blogs/blob/master/example/slot01.html
- 具名插槽 https://github.com/Sinosaurus/blogs/blob/master/example/slot02.html
作用域插槽 https://github.com/Sinosaurus/blogs/blob/master/example/slot-scope.html
总结:- 可以利用作用域插槽 进行子向父传值,但是有限制,只能在子组件中使用而已(暂时这么理解)
vue2.5以上可以不适用template进行也可以正常使用slot-scopeslot-scope可以分开,slot写具名插槽,scope写传过来的参数
vue2.5以上可以不适用template进行也可以正常使用slot-scopeslot-scope可以分开,slot写具名插槽,scope写传过来的参数





