Last active
July 9, 2019 02:40
-
-
Save Manyaka/314eb815c7304cf76aa4dab52898a5f4 to your computer and use it in GitHub Desktop.
Три способа получить пустой объект во Vue.js, потому что, из-за системы реактивности, в объект приезжают свойства от Observer.
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
props: { | |
someObject: { | |
type: Object, | |
default: () => ({}), | |
}, | |
}, | |
created() { | |
console.log(this.someObject); // {__ob__: Observer} | |
let variant1 = JSON.parse(JSON.stringify(this.someObject)); | |
console.log(variant1); // {} | |
let variant2 = { ...this.someObject }; | |
console.log(variant2); // {} | |
let variant3 = Object.assign({}, this.someObject); | |
console.log(variant3); // {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment