[英]Vue.js in Laravel
I am trying to use vue.js with laravel for the first time.我第一次尝试将 vue.js 与 laravel 一起使用。
In the blade.php file:在刀片.php 文件中:
<html>
<body class>
<div id="app">
<favourup></favourup>
</div>
<script src="{{ asset('js/app.js') }}"></script>
</body>
</html>
In the app.js file:在 app.js 文件中:
Vue.component('favourup', require('./components/Favourup.vue'));
const app = new Vue({
el: '#app',
});
In the vue file:在 vue 文件中:
<template>
<div>
<h2>FavourUp</h2>
</div>
</template>
I am not getting any errors however the local host displays an empty web page when it should display 'FavourUp'我没有收到任何错误,但是当本地主机应该显示“FavourUp”时,它会显示一个空的 web 页面
you should write.default at end of require vue components because of part of the vue-loader 15 updates, if your code uses the CommonJS syntax for importing EcmaScript modules, you'll need to append.default: https://laravel-mix.com/docs/4.0/upgrade#importing-es-modules but as @Ifaruki said you can import it too here's the code:由于 vue-loader 15 更新的一部分,你应该在 require vue 组件的末尾写上 default,如果你的代码使用 CommonJS 语法来导入 EcmaScript 模块,你需要 append.default: https://laravel-mix .com/docs/4.0/upgrade#importing-es-modules但正如@Ifaruki 所说,您也可以将其导入这里的代码:
// first
Vue.component('favourup', require('./components/Favourup.vue').default);
// second
import Favourup from './components/Favourup.vue';
Vue.component('favourup', Favourup);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.