2
병합하는 동안 두 개의 javascript 객체를 병합하는 방법을 검색하지만 null 값은 생략합니다. 나는 여기에 두 객체를 병합하지만 null 값을 생략합니다.
내 시험 ( JSFiddle)입니다 .... lodash와 병합, 할당 복제를 시도했지만 :let defaultValues = {code: '', price: 0, description: ''}
let product = {code: 'MyCode', price: null, description: 'Product Description'}
//I merge these two objects
let merged = _.merge({}, defaultValues, product)
console.log(merged)
//Result :
{code: 'MyCode', price: null, description: 'Product Description'}
//Expected result : (I want to keep price at 0 from defaultValues because is null in product)
{code: 'MyCode', price: 0, description: 'Product Description'}
내가 VueJS 프레임 워크를 사용하기 때문에이 문제에 대한 솔루션을 검색하고 나는이 널 (null)이있을 때 속성에 입력 (v를 모델), 난 예외가 ...
감사!