【问题标题】:How import component vue in script laravel blade如何在脚本 laravel Blade 中导入组件 vue
【发布时间】: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

我期待您的帮助。谢谢

【问题讨论】:

    标签: laravel vue.js


    【解决方案1】:

    重点是制作一个vue组件并在那里设置模板和脚本。然后,编译后,你可以在刀片中输入任何你想要的组件名称。

    FMI,你必须阅读How to create and deal with vue component in laravel

    【讨论】:

      猜你喜欢
      • 2020-01-27
      • 2017-10-28
      • 2016-02-03
      • 2022-08-20
      • 2019-01-30
      • 2016-03-14
      • 2020-11-12
      • 2020-07-02
      • 1970-01-01
      相关资源
      最近更新 更多