首页 > 解决方案 > laravel中vue的问题

问题描述

我正在尝试在我的 laravel 5.8 项目中实施 媒体管理器 3.6.7,但我遇到了 VUE 问题。(这是我第一次使用它)。

在控制台中,它给了我两个错误:空白页面的控制台错误,但是当我单击页面源时,我可以看到页面已呈现:页面源

我想我被困在这个:

// app.js
window.Vue = require('vue')
require('../assets/vendor/MediaManager/js/manager')
new Vue({
    el: '#app'
})

我应该把它放在哪里?如果我把它放在 media.blade.php 我得到 Require is not a function。如果我包括要求,还有另一个错误 Module name "vue" has not been loaded yet for context: _. Use require([])

如果我使用 require(['vue']) 我得到了 20 个错误..

这里有什么问题?前面的步骤已成功完成。

标签: laravelvue.js

解决方案


该错误清楚地表明您没有正确注册该组件。

在 app.js 文件中:

import ComponentA from '/*path of the file*/'
import ComponentB from '/*path of the file*/'

new Vue({
  el: '#app',
  components: {
    'my-notification': ComponentA,
    'media-manager': ComponentB
  }
})

推荐阅读