Skip to content

Commit

Permalink
docs: update Root#assign doc
Browse files Browse the repository at this point in the history
  • Loading branch information
imcuttle committed Mar 9, 2018
1 parent 2d9e8f7 commit 09418e1
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/Model/Root.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ export default class Root {
this[key] = data[key]
}
// }

}
}
return this
Expand All @@ -134,7 +133,7 @@ export default class Root {
* @memberof Root
*/
clone() {
return new this.constructor(this)
return this.constructor.create(this)
}

/**
Expand All @@ -154,13 +153,27 @@ export default class Root {
}

/**
* 批量赋值
* 批量赋值,如需要覆写 `assign`,请覆写 `assignShallow`
* @param {object | Root} data
* @returns {Root}
* @memberof Root
* @alias assignShallow
* @public
* @example
* Root.create().assign({ a: 'a', b: 'b' })
* Root
* .create()
* .assign({ a: 'a', b: 'b' })
* .assignShallow({ a: 'a', b: 'b' })
* // 支持嵌套赋值
* class Nested extends Root {
* \@observable root = Root.create({ a: 'c' })
* }
* Nested
* .create({ root: { b: 'b' } })
* .root instanceof Root // true
* Nested
* .create({ root: { b: 'b' } })
* .root.a === 'c' // true
*/
assign(data) {
return this.assignShallow(data)
Expand Down

0 comments on commit 09418e1

Please sign in to comment.