Brief introduction
Here is what I learned meteor,react
some code fragments and summary and related technology, continuously updated. . .
arrow function
Use the arrow functions:
- The use of braces, which must have a
return
statement - Use brackets, which do not have
return
keywords, and easy to read - Do not use brackets for a return statement, easy to read
1 |
Meteor.publish('posts.all', function() { |
mongo database chaining
Database structure:
- title —>string
- contents —>array
- name —>string
- read —>boolean
- …
- createdAt —> date
- …
Need to pass parameters:
- title —>string
- contentName —> string
- read —>boolean
The following shows: Find the title title
, and called the name of the contents of contentName
the article and read the value of its content isread
1 |
Posts.update( |
react dangerouslySetInnerHTML
Note braces, accepted object
1 |
<div dangerouslySetInnerHTML={{ __html: content }}> |
react component lifecycle methods
When you upload and display pictures, if you leave the page, and then back again, along with the last upload pictures, you need to call react
the life cycle of the function.
1 |
componentWillMount () { |
Large column using meteor / react during some of the code fragment headerlink "title =" summernote Editor display content "> summernote editor to display the contents of
Some incoming content is displayed, such as the contents of a section of html editor to make when initializing
1 |
// outermost wrapping editor and rendering html content by dangerouslySetInnerHTML |
api calls summernote editor
If we want to click on the Show or Hide button, the editor can dynamically display without refreshing the entire page, you need the following operations
1 |
// After entering the page, the editor initialization |
lodash array sorting performed in sortBy
For example, an article there are a lot of comments, you need to be sorted according to the number of comments, we can return the sorted array.
1 |
const singlePost = Posts.findOne(); |