【问题标题】:Using Vuetify in Laravel (Error: Vuetify is not properly initialized)在 Laravel 中使用 Vuetify(错误:Vuetify 未正确初始化)
【发布时间】:2020-01-22 00:47:57
【问题描述】:

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

我完全按照博客https://codersdiaries.com/laravel-vuetify/ 中所写的内容进行操作,并且在控制台中收到一条错误消息:[Vue warn]: Error in beforeCreate hook: "Error: Vuetify is not proper initialized强>

这是我的文件

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"
  }
}

【问题讨论】:

    标签: laravel vue.js vuetify.js


    【解决方案1】:

    你没有给 Vue 一个 Vuetify 实例:

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

    【讨论】:

      猜你喜欢
      • 2020-05-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-22
      • 2018-11-05
      • 1970-01-01
      • 1970-01-01
      • 2014-02-02
      相关资源
      最近更新 更多