问题描述
export default {
namespaced: true,
state: {
params: {
aa: '',
bb: [],
}
},
mutations: {
initParams(state) {
state.params = {
aa: '',
bb: [],
};
},
},
actions: {},
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
<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>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
解决方法
export default {
namespaced: true,
state: {
params: {
aa: '',
bb: [],
name: '',
}
},
mutations: {
initParams(state) {
state.params = {
aa: '',
bb: [],
name: '',
};
},
},
actions: {},
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20