Last active
January 28, 2016 03:08
-
-
Save Teevio/d7172e160a3aa67696fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If you don't care about IE | |
jsConfig.pageData = Object.assign({}, jsConfig.pageData, { [path]: data.page }) | |
// If you use Underscore.js | |
jsConfig.pageData = _.extend(jsConfig.pageData, { [path]: data.page }); | |
// If you use jQuery | |
jsConfig.pageData = jQuery.extend(true, jsConfig.pageData, { [path]: data.page }); | |
// Just JS | |
var tempData = (JSON.parse(JSON.stringify(this.someObject))); | |
tempData[path] = data.page; | |
jsConfig.pageData = tempData; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When dealing with state and reactivity with Vue.js you will sometimes need to assign a number of properties on to an existing object, for example using Object.assign() or _.extend(). However, new properties added to the object will not trigger changes. In such cases, create a fresh object with properties from both the original object and the mixin object (http://vuejs.org/guide/reactivity.html#Change_Detection_Caveats).