Laravel Vuetify安装

followed a tutorial on youtube (https://www.youtube.com/watch?v=cXGxO6KCR4g) for Vuetify setup with laravel. I managed to setup the project successfully, i.e. install all dependencies as specfied in the tutorial. Although in the final step, NPM watch, i get the following error in the console;

Uncaught TypeError: _plugins_vuetify__WEBPACK_IMPORTED_MODULE_1__.default is not a constructor

vuetify.js代码;

import Vuetify from 'vuetify/lib'

Vue.use(Vuetify)

const opts = {}

export default new Vuetify(opts)``


评论
  • Ctrl
    Ctrl 回复

    问题恰恰在于您导出默认Vuetify的位置。您不能像这样导出它,您要做的就是这样做:

    // plugins/vuetify.js
    
    import Vue from 'vue'
    import Vuetify from 'vuetify/lib'
    
    Vue.use(Vuetify)
    

    注意:您还可以在Vue.use中的上述文件中定义一些设置,并将其作为对象传递,如下所示:

    Vue.use(Vuetify, {/*Your setting goes here*/})
    

    And then import it like below in your main.js:

    // main.js
    
    import Vue from 'vue'
    import './plugins/vuetify' // We are supposed the above snippet is in the plugins directory and it lies next to main.js
    ...
    new Vue({
      el: "#app",
      router,
      store,
      render: h => h(App),
    })