使用require.js加载chartjs插件时出现问题

时间:2019-07-11 08:53:42

标签: charts knockout.js requirejs

为了自定义Chart.js,我想添加另一个库。 我很难为Chart.js加载库

该库是chartjs-plugin-datalabels。我正在使用chart.js 2.8.0

这是我的require.config.js文件

var require = {
urlArgs: "v=10",
baseUrl: "/",
waitSeconds: 0,
paths: {
    "bootstrap": "Scripts/bootstrap",
    "jquery": "Scripts/jquery-3.3.1",
    "blockUI": "Scripts/jquery.blockUI",
    "knockout": "Scripts/knockout-3.5.0",
    "momentjs": "Scripts/moment.min", //needed by chart js
    "chart": "Scripts/Chart.min", //chart js
    "chartjs-plugin-datalabels": "Scripts/chartjs-plugin-datalabels.min", //chartjs plugin
    "dataTables": "Scripts/DataTables/jquery.dataTables.min",
    "text": "Scripts/text",
    "sammy": "Scripts/sammy-0.7.5",
    "common": "App/common",
    "datepicker": "Scripts/bootstrap-datepicker",
    "datepickerITA": "Scripts/locales/bootstrap-datepicker.it",
    "toastr": "Scripts/toastr",
    "api": "App/api",
    "settings": "App/settings"
},
shim: {
    "bootstrap": {
        deps: ["jquery"]
    },
    "toastr": {
        deps: ["jquery"]
    },
    "blockUI": {
        deps: ["jquery"]
    },
    "dataTables": {
        deps: ["jquery"]
    },
    "chart": {
        deps: ["momentjs"]
    },
    "chartjs-plugin-datalabels": {
        deps: ["chart"]
    },
    "sammy": {
        deps: ["jquery"]
    },
    "common": {
        deps: ["knockout", "jquery"]
    },
    "datepicker": {
        deps: ["jquery", "bootstrap"]
    },
    "datepickerITA": {
        deps: ["jquery", "bootstrap", "datepicker"]
    },
    "api": {
        deps: ["jquery"]
    }
}

这是页面配置

define(["knockout", "text!./page-corso-progress.html", "toastr", "api", "common", "bootstrap", "chartjs-plugin-datalabels"], function (ko, pageTemplate, toastr, api, common, chart)

我在这里做错什么了?

0 个答案:

没有答案