【发布时间】:2019-05-23 17:52:48
【问题描述】:
使用以下代码
<template>
<div :id="svgId" class="svg-container"></div>
</template>
<script>
import { mapState } from 'vuex'
export default {
name: 'Space',
data: function() {
return {
svgId: 'space',
svgContainer: null
}
},
computed: mapState({
notes: state => state.notes
}),
mounted: function() {
this.generateSpace()
},
methods: {
generateSpace: function() {
this.$svg('space')
.rect(100, 100)
.attr({ fill: '#f06' })
}
}
}
</script>
我目前只画一个粉红色的正方形,但我想做的是在方法生成空间中使用来自商店的数据,但我不确定如何访问它,例如这样的东西;
this.$svg('space')
.rect(notes.height, notes.width)
.attr({ fill: notes.color })
}
感谢任何提示。
【问题讨论】: