misterGF / CoPilot

Responsive Bootstrap 3 Admin Template based on AdminLTE with vue.js
https://copilot.misterGF.io
2.92k stars 714 forks source link

when I run the demo, it throw the Exception.. #31

Closed ice-2022 closed 7 years ago

ice-2022 commented 7 years ago

TypeError: (0 , _jquery2.default)(...).DataTable is not a function at VueComponent.eval (eval at (app.js:1734), :21:42) at Array.eval (eval at (app.js:612), :511:20) at nextTickHandler (eval at (app.js:612), :460:16)

misterGF commented 7 years ago

Can you give us some more info?

What OS, node version, etc.

Does it happen when you click on the tables page or after you perform a certain action?

ice-2022 commented 7 years ago

windows7 and my node version is v6.10.2

it happen when i load page without any action

I run the code below:

import $ from 'jquery'
// Require needed datatables modules
import 'datatables.net'
import 'datatables.net-bs'

export default {
  name: 'Tables',
  mounted () {
    this.$nextTick(() => {
      console.log($)
      console.log($.DataTable)
      $('#example1').DataTable()
    })
  }
}

the result is: object undefined

misterGF commented 7 years ago

Please reference Euvl's comments on this. https://github.com/misterGF/CoPilot/issues/22

hooklife commented 6 years ago

@misterGF I have the same problem,how to fix it?

22 doesn't help me

[Vue warn]: Error in nextTick: "TypeError: $(...).DataTable is not a function"

hooklife commented 6 years ago
import $ from 'jquery'
// Require needed datatables modules
import 'datatables.net'
import dataTable from 'datatables.net-bs'

export default {
  name: 'User',
  mounted () {
    this.$nextTick(() => {
      $.fn.DataTable = dataTable   // <----- add this line
      $('#example1').DataTable()
    })
  }
}

it work!