gpt4 book ai didi

javascript - ReactJS中的props是什么,与Angular的$scope相同吗?

转载 作者:行者123 更新时间:2023-11-29 17:51:21 25 4
gpt4 key购买 nike

ReactJS 中的 props 是什么?与 AngularJS 的 $scope 相同吗?我似乎无法理解 react 中的 Prop ,因为我对它很陌生。预先感谢您。

最佳答案

它们并不等同:

Angular $scope 是一个定义 Controller 对象的变量/属性/函数的上下文的对象。
< br/>React props 是组件函数/类消耗的实际任意值


React docs :

"Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called "props") and return React elements describing what should appear on the screen."

Angular docs :

"Scope is an object that refers to the application model. It is an execution context for expressions."

关于javascript - ReactJS中的props是什么,与Angular的$scope相同吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43414076/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com