在Laravel中使用Vuetify(错误:未正确初始化Vuetify)

时间:2019-09-21 04:03:55

标签: laravel vue.js vuetify.js

我正在使用Laravel 5.8,默认情况下其中包含Vue JS,我想使用Vuetify。这是我所做的

我完全遵循博客https://codersdiaries.com/laravel-vuetify/中的内容,并且在控制台中收到一条错误消息,该错误消息是 [Vue警告]:beforeCreate挂钩中的错误:“错误:Vuetify未正确初始化

这是我的文件

  

welcome.blade.php

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Laravel</title>

    <link href='https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons' rel="stylesheet">

    <script src="{{ asset('js/app.js') }}" defer></script>

</head>

<body>
    <v-app id="app">
        <h1>Test Vuetify</h1>
    </v-app>
</body>

</html>
  

app.js

window.Vue = require('vue');
import Vuetify from 'vuetify'
Vue.use(Vuetify)


Vue.component('example-component', require('./components/ExampleComponent.vue').default);

const app = new Vue({
    el: '#app',
});
  

package.json

{
  "private": true,
  "scripts": {
    "dev": "npm run development",
    "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "npm run development -- --watch",
    "watch-poll": "npm run watch -- --watch-poll",
    "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "prod": "npm run production",
    "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
  "devDependencies": {
    "axios": "^0.19",
    "cross-env": "^5.1",
    "laravel-mix": "^4.0.7",
    "lodash": "^4.17.13",
    "resolve-url-loader": "^2.3.1",
    "sass": "^1.15.2",
    "sass-loader": "^7.1.0",
    "vue": "^2.5.17",
    "vue-template-compiler": "^2.6.10"
  },
  "dependencies": {
    "vuetify": "^2.0.18"
  }
}

1 个答案:

答案 0 :(得分:4)

您没有为Vue提供Vuetify实例:

const vuetify = new Vuetify();

const app = new Vue({
    el: '#app',
    vuetify
});