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
| <template> <div :id="uniqueID"></div> </template> <script> import uuid from 'uuid/v1' export default { name: 'chart', props: { options: { type: Array } }, data () { return { uniqueID: '' } }, created () { this.uniqueID = uuid() }, mounted () { const options = { title: { x: 'center' }, ... }, - let chart = echarts.init(querySelector(this.uniqueID)) + let chart = echarts.init(getElementById(this.uniqueID)) chart.setOption(options) } } </script>
|