首页 > 解决方案 > 在 vue3 组件中导入 bower 组件 - WEBPACK_IMPORTED_MODULE_1_.Timetable 不是构造函数

问题描述

我想在我的 Vue3 组件中使用外部库“时间表”(http://timetablejs.org/ )。

我的组件:

<script>
import axios from 'axios';
import { Timetable } from '../../bower_components/timetable.js/dist/scripts/timetable.js'

export default {
  name: 'Planning',
  data() {
    return {}
  },
  mounted: function(){

    var timetable = new Timetable();

  }
}
</script>
<style>
  @import '../../bower_components/timetable.js/dist/styles/timetablejs.css';
</style>
<template>
  <div>
      <div class="timetable"></div>
  </div>
</template>

当我想创建一个新的时间表时,我有一个错误:

未捕获(承诺)类型错误:bower_components_timetable_js_dist_scripts_timetable_js__WEBPACK_IMPORTED_MODULE_1_.Timetable 不是构造函数

我无法用 npm 安装库,我用 bower 安装了它。如何将这个 bower 组件与我的 Vue3 组件一起使用?

标签: javascriptimportbowervuejs3

解决方案


推荐阅读