【发布时间】:2019-10-04 21:59:15
【问题描述】:
我想做一个组件 vue 的引用,像这个链接:https://jsfiddle.net/xmqgnbu3/1/。
但是,在这段代码中,代码组件和js代码在同一个页面中。 我在 vue 中使用 laravel,组件在另一个文件夹中(链接:https://ibb.co/g3CvHz6)
我尝试了所有这些,但我在“require”中的“import”中有错误:
@section('contenido')
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<div id="app" class="container">
<matricula ref="matri"></matricula>
</div>
<input type="hidden" id="csrf_token" value="{{ csrf_token() }}" />
<script src="{{ elixir('js/app.js') }}"></script>
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script>
import MatriculaComponent from '../js/components/MatriculaComponent.vue';
let MatriculaComponent=require('../js/components/MatriculaComponent.vue');
var vm = new Vue({ el: '#app', components: { matricula } });
var vm=$("#app")
function createItem(){
//this.$refs["matri"].Prueba();
//vm.$refs.matri.Prueba();
//vm['my-component'].Prueba();
console.log("la referencia: "+this.$refs.matri.Prueba())
//this.$refs.matricula.Prueba();
}
</script>
@endsection
我期待您的帮助。谢谢
【问题讨论】: