使用Materialize和jQuery的VueJS

时间:2017-07-12 03:04:51

标签: jquery vuejs2 materialize

我使用vue init webpack来生成我的项目,npm install jquerynpm install materialize-css来安装依赖项,但我有错误。

我试图使用具体化modal javascript

这是错误:

Uncaught TypeError: $ is not a function
at eval (eval at <anonymous> (app.js:977), <anonymous>:7595:11)
at eval (eval at <anonymous> (app.js:977), <anonymous>:8269:2)
at Object.<anonymous> (app.js:977)
at __webpack_require__ (app.js:660)
at fn (app.js:86)
at eval (eval at <anonymous> (app.js:772), <anonymous>:6:74)
at Object.<anonymous> (app.js:772)
at __webpack_require__ (app.js:660)
at fn (app.js:86)
at Object.<anonymous> (app.js:958)

这是main.js

import Vue from 'vue'
import App from './App'
import router from './router'
import Materialize from 'materialize-css'
import jQuery from 'jquery'

Vue.use(Materialize)
Vue.use(jQuery)

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  template: '<App/>',
  components: { App }
})

这是我的vue文件

<template>
  <div>
    <v-btn-link v-modal:modal>Modal</v-btn-link>
    <v-modal id="modal">
      <div slot="content">
        <h4>Modal Header</h4>
        <p>A bunch of text</p>
      </div>
      <div slot="footer">
        <v-btn-link class="pull-right" waves-light modal flat>Disagree</v-btn-link>
        <v-btn-link class="pull-right" waves-light modal flat>Agree</v-btn-link>
      </div>
    </v-modal>
  </div>
</template>

<script>
  export default {
  }
</script>

这个项目只是一个测试,因为我正在学习VueJS。

有谁知道如何解决这个问题?

0 个答案:

没有答案