You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
React.render(<h1>Hello, world from React.js!</h1>, document.getElementById('example'))
146
143
```
147
144
148
145
> Because we are using the `react-tools` node package, we want to add the compiled javascript code to our templates. Change you `views/layout.jade` file to the following:
Copy file name to clipboardExpand all lines: 前端/2015-06-06-reactjs_tutorial_part_2.md
+23-23Lines changed: 23 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,11 +35,11 @@ $ npm install --save-dev gulp
35
35
Gulp 安装好之后,我们建立一个`gulpfile.js`文件:
36
36
37
37
```js
38
-
var gulp =require("gulp");
38
+
var gulp =require('gulp')
39
39
40
-
gulp.task("default", function () {
40
+
gulp.task('default', function () {
41
41
// place code for your default task here
42
-
});
42
+
})
43
43
```
44
44
45
45
> Now we need to install the Gulp packages that we will need to build our application. To start, let's install [browserify](https://www.npmjs.com/package/browserify), [reactify](https://www.npmjs.com/package/reactify) and [vinyl-source-stream](https://www.npmjs.com/package/vinyl-source-stream). To install these packages, run the following command:
> Now running `gulp` from the command line will trigger the build of our React app; however, there are some things we need to do to our react app first!
> This file is taking our `HelloWorld` component and rendering it in the div with id "example". This code is taken from our original `helloworld.jsx` file from last tutorial. Instead of doing everything in that file, we are now requiring a module `HelloWorld` and rendering it in `app.jsx`. The reason for this is that as our application gets more complex, we have more control of how our files are broken out.
return<h1>Hello, world from a React.js Component!</h1>;
125
+
return<h1>Hello, world from a React.js Component!</h1>
126
126
},
127
-
});
127
+
})
128
128
```
129
129
130
130
> Notice that the `HelloWorld.jsx` and `app.jsx` files are combined to be very similar to how the 'helloworld.jsx' looked. Again, the reason for breaking our app into these two files are for future modules to be added.
var $ = (jQuery =require("../../libraries/jquery/dist/jquery"));
167
-
var bootstrap =require("../../libraries/bootstrap-sass-official/assets/javascripts/bootstrap");
166
+
var $ = (jQuery =require('../../libraries/jquery/dist/jquery'))
167
+
var bootstrap =require('../../libraries/bootstrap-sass-official/assets/javascripts/bootstrap')
168
168
```
169
169
170
170
> Doing this points both `jQuery ($)` and `bootstrap` to the appropriate file which were installed via Bower. When we re-run our browserify gulp task, these two libraries get pulled in! Simple as that.
0 commit comments