我正在使用几个外部库在 vue 应用程序中构建带有工具提示的图表。我正在使用单文件组件
我有一个工作小提琴,但无法将它翻译成一个工作组件。
尝试的方法:
<head>在标签中加载 3 个 tooltip-realted 脚本"TypeError: tooltipAnchor.tooltip is not a function"
加载标签中的 3 个 tooltip-realted 脚本
<body>,在已编译 vue 代码的标签之前 (build.js)"TypeError: tooltipAnchor.tooltip is not a function"
在钩子中的
Chart.vue组件中加载 3 个 tooltip-realted 脚本mounted"TypeError: tooltipAnchor.tooltip is not a function"
图表.vue:
mounted: function mounted() {
this.loadJS('https://code.jquery.com/jquery-3.2.1.slim.min.js')
.then(() => {
console.log('jquery loaded');
return this.loadJS('https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js');
})
.then(() => {
console.log('popper loaded');
return this.loadJS('https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js')
})
.then(() => {
console.log('bootstrap loaded');
this.buildChart();
});
},
methods: {
loadJS: function loadJS(url) {
return this.$http.get(url);
}
...
}
要求所有三个脚本都位于顶部
Chart.vue:- Bootstrap 无法加载,因为
jQuery它没有可用的全局变量
- Bootstrap 无法加载,因为
我怀疑当我将它们放入时加载的订单脚本有问题index.html,但我不知道是什么。有谁知道jsfiddle如何编译它的html?我还缺少什么?