我正在尝试使用Highcharts和Vue.js创建图形组件.我想传递要由Highcharts使用的元素的id属性,但是我无法获取该属性.
如何动态设置id?
这是HTML:
<objective-chart :element="'brick-chart'"></objective-chart>Run Code Online (Sandbox Code Playgroud)
和javascript代码:
<template>
<div id="{{element}}"></div>
</template>
<script>
import Highcharts from 'highcharts';
export default{
props: ['element'],
ready(){
$(function () {
new Highcharts.Chart({
chart: {
renderTo: this.element,
type: 'bar',
height: 200,
margin: [0, 20, 0, 40]
},
title: {
text: null
},
xAxis: {
lineColor: null,
labels: {
rotation: -90
},
categories: [
'Brick'
]
},
yAxis: [{
min: 0,
max:100,
endOnTick: true,
maxPadding: 0.02,
gridLineColor: null,
title: {
text: null
},
labels: {
y: -50
},
}], …Run Code Online (Sandbox Code Playgroud)