Problem Description
export default {
namespaced: true,
state: {
params: {
aa: '',
bb: [],
}
},
mutations: {
initParams(state) {
state.params = {
aa: '',
bb: [],
};
},
},
actions: {
},
}
<template>
<child childParams="params"/>
</template>
<script>
import {
mapState } from 'vuex';
import child from '@/components/child';
export default {
props: {
options: Object,
},
components: {
child },
data() {
return {
};
},
computed: {
...mapState('we-server/insight', ['params']),
},
methods: {
},
watch: {
options: {
handler(now) {
this.params.name = now.name;
console.log('64 params =', this.params.name);
},
deep: true,
},
},
mounted() {
},
};
</script>
Solution
- Just set an initialized attribute value for
params
object
export default {
namespaced: true,
state: {
params: {
aa: '',
bb: [],
name: '',
}
},
mutations: {
initParams(state) {
state.params = {
aa: '',
bb: [],
name: '',
};
},
},
actions: {
},
}