【问题标题】:Trying to use "fusionchart plugin" for Vue Js without the use of the import functionality / NPM尝试在不使用导入功能/NPM 的情况下为 Vue Js 使用“fusionchart 插件”
【发布时间】:2020-09-10 17:53:11
【问题描述】:

问题
目前,我正在按照下面显示的链接中的 fusionchart 指南进行操作。他们设置的唯一问题是他们使用了我无法使用的 IMPORT 功能。

我的问题
有没有办法通过例如 CDN 使插件在我的 html 文件中工作并且没有 IMPORT 功能?

Fusionchart 插件
https://www.fusioncharts.com/dev/getting-started/vue/your-first-chart-using-vuejs?utm_source=downloadPackage&utm_medium=referral&utm_campaign=trial

我的尝试
关于CDN,我尝试实现这部分没有多大成功,下面是我目前的代码:

<html>
<head>
    <script type="text/javascript" src="https://unpkg.com/vue@2.3.3"></script>
    <script type="text/javascript" src="https://unpkg.com/fusioncharts/fusioncharts.js"></script>
    <script type="text/javascript" src="https://unpkg.com/fusioncharts/fusioncharts.charts.js"></script>
    <script type="text/javascript"
        src="https://unpkg.com/fusioncharts@3.12.1/themes/fusioncharts.theme.fint.js"></script>
    <script type="text/javascript" src="https://unpkg.com/vue-fusioncharts/dist/vue-fusioncharts.min.js"></script>
    <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
    <style>
        body {
            font-family: Roboto;
            font-size: 12px;
        }
    </style>
</head>

<body>
    <!-- demo root element -->
    <div id="chart1">
        <fusioncharts :type="type" :dataformat="dataFormat" :datasource="dataSource" :width="width" :height="height"
            :events="events" ref="fusioncharts">
        </fusioncharts>
        <p class="message-box">
            The value that you have selected is: {{ displayValue }}
        </p>
    </div>

    <script type="text/javascript">
        Vue.use(VueFusionCharts);

        // bootstrap the demo
        var chart = new Vue({
            el: '#chart1',
            data: {
                type: 'Column2D',
                width: '500',
                height: '300',
                dataFormat: 'json',
                dataSource: {
                    chart: {
                        caption: 'Vue FusionCharts Sample',
                        theme: 'fint'
                    },
                    data: [{ value: 1.9 }, { value: 2.3 }, { value: 2.1 }]
                },
                displayValue: 'nothing',
                events: {
                    dataplotRollover: function (ev, props) {
                        chart.displayValue = props.displayValue;
                    }
                }
            }
        });
    </script>
</body>
</html>

我在控制台中遇到的错误

vue@2.3.3:440 [Vue warn]: Error in mounted hook: "TypeError: e is not a constructor"

found in

---> <Fusioncharts>
       <Root>
warn @ vue@2.3.3:440
handleError @ vue@2.3.3:525
callHook @ vue@2.3.3:2562
insert @ vue@2.3.3:3381
invokeInsertHook @ vue@2.3.3:5204
patch @ vue@2.3.3:5369
Vue._update @ vue@2.3.3:2320
updateComponent @ vue@2.3.3:2443
get @ vue@2.3.3:2780
Watcher @ vue@2.3.3:2763
mountComponent @ vue@2.3.3:2447
Vue$3.$mount @ vue@2.3.3:7564
Vue$3.$mount @ vue@2.3.3:9663
Vue._init @ vue@2.3.3:4004
Vue$3 @ vue@2.3.3:4089
(anonymous) @ index.html:38
vue@2.3.3:529 TypeError: e is not a constructor
    at VueComponent.renderChart (vue-fusioncharts.min.js:1)
    at VueComponent.boundFn [as renderChart] (vue@2.3.3:171)
    at VueComponent.mounted (vue-fusioncharts.min.js:1)
    at callHook (vue@2.3.3:2560)
    at Object.insert (vue@2.3.3:3381)
    at invokeInsertHook (vue@2.3.3:5204)
    at Vue$3.patch [as __patch__] (vue@2.3.3:5369)
    at Vue$3.Vue._update (vue@2.3.3:2320)
    at Vue$3.updateComponent (vue@2.3.3:2443)
    at Watcher.get (vue@2.3.3:2780)

【问题讨论】:

    标签: javascript html vue.js cdn fusioncharts


    【解决方案1】:

    似乎我包含的 CDN 出现了一些问题,我对此进行了更改,并且代码可以正常运行。

        <html>
    <head>
        <script type="text/javascript" src="https://unpkg.com/vue@2.3.3"></script>
        <script type="text/javascript" src="https://unpkg.com/fusioncharts/fusioncharts.js"></script>
        <script type="text/javascript" src="https://unpkg.com/fusioncharts/fusioncharts.charts.js"></script>
        <script type="text/javascript" src="https://rawgit.com/fusioncharts/vue-fusioncharts/feature/plugin-development/dist/vue-fusioncharts.js"></script>
        <script type="text/javascript" src="https://unpkg.com/fusioncharts/themes/fusioncharts.theme.fint.js"></script>
    </head>
    <body>
        <!-- demo root element -->
        <div id="chart1">
            <fusioncharts
                :type="type"
                :dataformat="dataFormat"
                :datasource="dataSource"
                :width="width"
                :height="height"
                :events="events"
                ref="fusioncharts"
            >
            </fusioncharts>
            <p class="message-box">The value that you have selected is: {{displayValue}} </p>
        </div>
    
        <script type="text/javascript">
            Vue.use(VueFusionCharts);
    
            // bootstrap the demo
            var chart = new Vue({
                el: '#chart1',
                data: {
                    type: 'Column2D',
                    width: '500',
                    height: '300',
                    dataFormat: 'json',
                    dataSource: {
                        chart: {
                            caption: 'Vue FusionCharts Sample',
                            theme: 'fint'
                        },
                        data: [{value: 1.9}, {value: 2.3}, {value: 2.1}]
                    },
                    displayValue: 'nothing',
                    events: {
                        dataplotRollover: function (ev, props) {
                            chart.displayValue = props.displayValue       
                        }       
                    }
                }
            });
        </script>
    </body>
    
    </html>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-10
      • 2018-11-03
      • 2023-02-21
      • 2018-02-04
      • 2019-02-09
      • 2021-02-18
      • 2017-12-14
      • 1970-01-01
      相关资源
      最近更新 更多