This article mainly introduces some examples of implementing AngularJS commands in the JavaScript React framework. React uses VirtualDOM, which is somewhat different from the common js framework, for more information, see the ng-class:
Angularjs ng-class setting style code, which is easy to understand. How can we implement it using React?
First, set a variable such as isShowLoginMenu in state, change its value in different scenarios, and then bind it to the class style.
Or
With Angularjs, we can do this:
Logged On
Hello, {userName}
Not logged on
How can we implement such a scenario using React?
React. createClass ({getInitialState: function () {return {isLogin: true, userName: 'job'} ;}, render: function () {var isLogin = this. state. isShowLoginMenu, loginHtml; if (isLogin) {loginHtml =Logged on. Welcome to {this. state. userName}
;} Else {loginHtml =Not logged on
;} Return ({LoginHtml}
);}