question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support and usage on Vue 3

See original GitHub issue

Description

Some weeks ago I migrated an app with bootstrap table to Vue 3. For any reason, the table does not work anymore. I suspect the problem is that BT is not supported on Vue 3.

What I expected

Use BT in a component like

<BootstrapTable :columns="columns" :data="data" :options="options"></BootstrapTable>

What I got

Uncaught TypeError: Cannot read property ‘fn’ of undefined

What I’ve tried so far

  • Followed the instructions on the https://bootstrap-table.com/docs/vuejs/webpack/ page.
  • Imported jquery on main.js and directly on the component

The only issue I have found is that for BT, jquery is undefined, which I do not fully understand, as I load jquery before BT.

Has anyone come across the same issue before?

Thanks in advance

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10

github_iconTop GitHub Comments

2reactions
daviidchanncommented, Dec 9, 2020

I’m trying to use Bootstrap Table but I’m getting this error;

Uncaught TypeError: Cannot read property ‘methods’ of undefined at eval (bootstrap-table-vue.esm.js?95f0:2126) at Module.eval (bootstrap-table-vue.esm.js?95f0:2145) at eval (bootstrap-table-vue.esm.js:2288) at Module…/node_modules/bootstrap-table/dist/bootstrap-table-vue.esm.js (app.js:1309) at webpack_require (app.js:833) at fn (app.js:130) at eval (cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/components/profile/InvoiceList.vue?vue&type=script&lang=js&:6) at Module…/node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/components/profile/InvoiceList.vue?vue&type=script&lang=js& (app.js:1576) at webpack_require (app.js:833) at fn (app.js:130)

I follow the doc https://bootstrap-table.com/docs/vuejs/webpack/

1reaction
waleevcommented, Apr 26, 2021

No problem. main.js:

import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

import BootstrapTable from '@/plugins/table'

const app = createApp(App)

app.component('BootstrapTable', BootstrapTable)

app.use(store).use(router).mount('#app')

I have included some extensions in plugins/table.js file:

import 'bootstrap/dist/css/bootstrap.min.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'
import 'bootstrap-table/dist/bootstrap-table.min.css'

import './jquery'
import 'bootstrap'
import 'bootstrap-table/dist/bootstrap-table.js'
import 'bootstrap-table/dist/locale/bootstrap-table-ru-RU.js'
import BootstrapTable from 'bootstrap-table/dist/bootstrap-table-vue.esm.js'

import 'dragtable/dragtable.css'
import 'dragtable/jquery.dragtable.js'
import 'bootstrap-table/dist/extensions/reorder-columns/bootstrap-table-reorder-columns.js'

import 'jquery-resizable-columns'
import 'jquery-resizable-columns/dist/jquery.resizableColumns.css'
import 'bootstrap-table/dist/extensions/resizable/bootstrap-table-resizable.js'

import 'bootstrap-table/dist/extensions/filter-control/bootstrap-table-filter-control.css'
import 'bootstrap-table/dist/extensions/filter-control/bootstrap-table-filter-control.js'

import 'bootstrap-table/dist/extensions/cookie/bootstrap-table-cookie.js'

export default BootstrapTable

And plugins/jquery.js looks like this:

import jQuery from 'jquery'

import 'jquery-ui/themes/base/core.css'
import 'jquery-ui/themes/base/theme.css'
import 'jquery-ui/themes/base/sortable.css'
import 'jquery-ui/themes/base/resizable.css'

import 'jquery-ui/ui/core'
import 'jquery-ui/ui/widgets/sortable'
import 'jquery-ui/ui/widgets/resizable'

window.$ = jQuery
window.jQuery = jQuery

Finally, use component where you need:

<BootstrapTable ref="table"
  :columns="columns" :data="data" :options="options"
/>

Hope this can help you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Frequently Asked Questions - Vue.js
What browsers does Vue support? #. The latest version of Vue (3.x) only supports browsers with native ES2015 support. This excludes IE11. Vue...
Read more >
Vue.js 3 support - BootstrapVue
@vue/compat support is designed for early migration to Vue.js 3 and will be ... You can use this sandbox for reference or reporting...
Read more >
New features in Vue 3 and how to use them - LogRocket Blog
Learn how to use the newest features in Vue 3 ahead of its official release including global mounting, portals, and Suspense.
Read more >
What's new in Vue 3 — a roundup. Vue 3 - Medium
Why Vue 3? · Blazing fast, Vite-powered build toolchain · More ergonomic Composition API syntax via <script setup> · Improved TypeScript IDE support...
Read more >
Yes, Vue 3 is out but you probably don't need it ‍♂️ - ITNEXT
When to use Vue 3 and when not to · If you need IE11 support: don't use it, support is not there yet...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found