1. 程式人生 > >解決vue用chart元件不渲染問題

解決vue用chart元件不渲染問題

在元件linechart裡這麼寫

<script>
    import { Line } from 'vue-chartjs';

    export default {
        extends: Line,
        data() {
            return {
                datacollection: {

                        labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
                        datasets: [{
                                label: 'success'
, backgroundColor: '#FC2525', fill: 'transparent', data: [40, 39, 10, 40, 39, 80, 40] }, { label: 'fail', backgroundColor: '#05CBE1'
, fill: 'transparent', data: [60, 55, 32, 10, 2, 12, 53] } ] } } }, mounted() { console.log("slkslkf"); this.renderChart(this
.datacollection, { responsive: false, maintainAspectRatio: false }) } }
</script>

然後在要用的地方 (dashboard)裡面引入註冊之後 要手動設定 長和高 要不然inspect每次都是height=0 這個元件每次都出不來 我也覺得非常迷

 <line-chart :width="1675" :height="250"></line-chart>