const props = defineProps({
a: Object
})
function calcs() {
var b = props.a;
b.push({
xxx: yyy
});
}
eg a={x: 'y'}
I need b to be {x: 'y'} before b.push each time when call function calcs, but b keep pushing xxx:yyy, any solutions? I tried ref(props.a), reactive(props.a), still not working
1st call calcs, the output is props.a={x: 'y'}
b={x: 'y',xxx: 'yyy'}
2nd call calcs, the output become props.a={x: 'y',xxx: 'yyy'}
b={x: 'y',xxx: 'yyy',xxx: 'yyy'}
3rd call calcs, the output become props.a={x: 'y',xxx: 'yyy',xxx: 'yyy'}
b={x: 'y',xxx: 'yyy',xxx: 'yyy',xxx: 'yyy'}
I have no idea the prop a changes after each call, how can I get the output the same as the 1st call which is props.a={x: 'y'}
b={x: 'y',xxx: 'yyy'}
thanks, im new to vue.
var b = JSON.parse(JSON.stringify(props.a)) fixed the issue.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.