Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the function of the context parameter

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

本篇内容主要讲解"context参数有什么作用",感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习"context参数有什么作用"吧!

由官方文档可知:context参数如下:一个包含了所有父组件为当前组件注册的事件监听器的对象。这是data.on的一个别名。

context参数怎样

props:提供所有prop的对象

children:VNode子节点的数组

slots:一个函数,返回了包含所有插槽的对象

scopedSlots:(2.6.0+)一个暴露传入的作用域插槽的对象。也以函数形式暴露普通插槽。

data:传递给组件的整个数据对象,作为createElement的第二个参数传入组件

parent:对父组件的引用

listeners:(2.3.0+)

injections:(2.3.0+)如果使用了inject选项,则该对象包含了应当被注入的属性。

context参数使用函数式组件

hellobutton

importFuncButtonfrom'../function-components/func-button'

exportdefault{

name:'home',

components:{

FuncButton

}

}

(数组|String),我们可以让父组件去控制组件的button按钮内容,改写如下:

//exportdefault{

//name:'functional-button',

//functional:true,

//render(h,context){

//returnh('button','按钮1号')

//}

//}

exportdefault{

name:'funtional-button',

functional:true,

render(h,{children}){

returnh('button',children)

}

}

到此,相信大家对"context参数有什么作用"有了更深的了解,不妨来实际操作一番吧!这里是网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report