When you assign the values in(当您在中分配值时)
chartStyleObject: {
width: this.$store.state.chartStyleObject.width, // here
height: this.$store.state.chartStyleObject.height,
marginTop: this.$store.state.chartStyleObject.marginTop,
marginRight: this.$store.state.chartStyleObject.marginRight,
marginBottom: this.$store.state.chartStyleObject.marginBottom,
marginLeft: this.$store.state.chartStyleObject.marginLeft,
},
you are assigning values to the width
, height
and so on.(您正在为width
, height
等分配值 。) You assign to them the current values of the state
variables.(您为他们分配state
变量的当前值 。)
If you want the properties of chartStyleObject
to change whenever the store's state
changes, either map the state
directly in the template (or wheverever you use it) or create a computed:(如果您希望在商店的state
发生变化时, chartStyleObject
的属性发生变化,请直接在模板中映射state
(或在使用状态时),或者创建一个计算式:)
export default {
computed: {
chartStyleObject() {
return {
width: this.$store.state.chartStyleObject.width,
height: this.$store.state.chartStyleObject.height,
marginTop: this.$store.state.chartStyleObject.marginTop,
marginRight: this.$store.state.chartStyleObject.marginRight,
marginBottom: this.$store.state.chartStyleObject.marginBottom,
marginLeft: this.$store.state.chartStyleObject.marginLeft,
};
},
},
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…