Php vuejs组件未在my laravel 5.3刀片页面中呈现
我使用的是laravel 5.3和vue 1.0.26版本,无法将组件加载到刀片页面中。它是空的。我只是尝试使用给定的laravel示例组件 如果任何机构有解决方案,请提出建议 我的app-laravel.js文件Php vuejs组件未在my laravel 5.3刀片页面中呈现,php,jquery,vue.js,laravel-5.3,Php,Jquery,Vue.js,Laravel 5.3,我使用的是laravel 5.3和vue 1.0.26版本,无法将组件加载到刀片页面中。它是空的。我只是尝试使用给定的laravel示例组件 如果任何机构有解决方案,请提出建议 我的app-laravel.js文件 require('./bootstrap'); Vue.component('example', require('./components/Example.vue')); const app = new Vue({ el: '#app' }); 我的刀片页面看起来像 &l
require('./bootstrap');
Vue.component('example', require('./components/Example.vue'));
const app = new Vue({
el: '#app'
});
我的刀片页面看起来像
<div class="col-10 text-muted">
<div id="app">
<example></example>
</div>
</div>
elixir(mix => {
mix.sass('app.scss', 'public/css/app.min.css')
.scripts([
'../../../node_modules/jquery/dist/jquery.min.js',
'libraries/datatables.responsive.js',
'libraries/datatables.responsive.bootstrap4.js',
'../../../node_modules/vue/dist/vue.min.js',
'app.js',
], 'public/js/app.min.js');
});
这里是我的Example.vue文件
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">Example Component</div>
<div class="panel-body">
I'm an example component!
</div>
</div>
</div>
</div>
</div>
<script>
export default {
ready() {
console.log('Component ready.')
}
}
</script>
示例组件
我是一个示例组件!
导出默认值{
就绪(){
console.log('组件就绪')
}
}
查看Vue组件文件后,尝试进行这些更改,看看是否仍有问题
<template> <!-- First open a template tag -->
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">Example Component</div>
<div class="panel-body">
I'm an example component!
</div>
</div>
</div>
</div>
</div>
</template> <!-- Close template tag -->
<script>
// Try using module.exports instead of export default
module.exports = {
}
</script>
示例组件
我是一个示例组件!
//尝试使用module.exports而不是export default
module.exports={
}
您需要先导入vue,编写如下代码
//import vue
import Vue from 'vue';
//register component
Vue.component('yourComponentName',require('./components/yourComponentName.vue').default);
//initialize vue
const app = new Vue({
el: '#app',
});
无法在
主体上装载Vue实例。将所有内容放入
并装载到#app
中,即使我尝试过,也无法正常工作,无论其他问题如何,装载到主体
肯定也无法正常工作,请使用vue.js
而不是vue.min.js
,以便从vue获取错误消息,这将有助于包含我的app-laravel.js文件const-app=new-Vue({el:'#app'});没有人仍然有同样的问题。请建议,如果发现任何其他问题,对不起,所有,我没有在主布局文件中添加,现在它是工作良好,谢谢大家