php laravel vue,laravel vue 组件的问题

刚开始使用laravel 结合vue 组件的例子:按照教程编写如下例子

主要使用了3个文件 welcomeComponent.vue, app.js 和index.blade.php

目录结构如下

bVbm9QK?w=272&h=442

welcomeComponent.vue文件内容

<style>

</style>

<template>

<div class="alert alert-primary" role="alert">

<strong>primary</strong>

</div>

</template>

<script>

export default {}

</script>

app.js 文件内容

require('./bootstrap');

window.Vue = require('vue');

Vue.component('example-component', require('./components/ExampleComponent.vue').default);

Vue.component('welcome-component', require('./components/WelcomeComponent.vue'));

const app = new Vue({

el: '#app'

});

index.blade.php

<!doctype html>

<html lang="{{ app()->getLocale() }}">

<head>

<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Laravel</title>

<link href="{{ asset('css/app.css')  }}" rel="stylesheet">

</head>

<body>

<div id="app">

<welcome-component></welcome-component>

</div>

<script src="{{ asset('js/app.js') }}"></script>

</body>

</html>

现在遇到的问题:

app.js 中定义全局组件时,加上.default就正常,如果去掉.default部分就失败

bVbm9Rr?w=769&h=182

失败信息

bVbm9RC?w=544&h=170

非常困惑,非常困惑

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值