本例中的VueJs图表应用程序在IE中不起作用。有人知道为什么吗?
例如,以下组件不会打印错误,但不会同时运行
<div class="app">
{{ message }}
<line-chart></line-chart>
</div>
Vue.component('line-chart', {
extends: VueChartJs.Line,
mounted () {
this.renderChart({
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [
{
label: 'Data One',
backgroundColor: '#f87979',
data: [40, 39, 10, 40, 39, 80, 40]
}
]
}, {responsive: true, maintainAspectRatio: false})
}
})
var vm = new Vue({
el: '.app',
data: {
message: 'Hello World'
}
})
发布于 2017-11-02 07:11:33
这是因为,在您的组件中使用了一个ES6语法来定义对象方法,如下所示:
mounted () {
..。Internet中还不支持ES6语法。
相反,如果您希望支持IE,则必须在所有组件/应用程序中使用ES5语法:
Vue.component('line-chart', {
extends: VueChartJs.Line,
mounted: function() { //<- use this instead
this.renderChart({
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [{
label: 'Data One',
backgroundColor: '#f87979',
data: [40, 39, 10, 40, 39, 80, 40]
}]
}, {
responsive: true,
maintainAspectRatio: false
})
}
});
看一个工作实例。
https://stackoverflow.com/questions/47069260
复制相似问题