[英]Cannot setup and run vuejs in laravel
I am quite new to vue.js but familiar with laravel. 我对vue.js相当陌生,但是对laravel很熟悉。 Now with laravel 5.3 release, am trying to run some sample application using vue. 现在有了laravel 5.3版本,我正在尝试使用vue运行一些示例应用程序。
resources/js/app.js : resources / js / app.js:
/**
* First we will load all of this project's JavaScript dependencies which
* include Vue and Vue Resource. This gives a great starting point for
* building robust, powerful web applications using Vue and Laravel.
*/
require('./bootstrap');
/**
* Next, we will create a fresh Vue application instance and attach it to
* the body of the page. From here, you may begin adding components to
* the application, or feel free to tweak this setup for your needs.
*/
new Vue({
el: 'body',
data: {
message: 'Hello Vue World!'
}
})
welcome.blade.php welcome.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="{{ elixir('js/app.js') }}"></script>
<link rel="stylesheet" href="{{ elixir('css/app.css') }}">
<title>Laravel</title>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Raleway:100,600"
rel="stylesheet" type="text/css">
</head>
<body>
<div id="app">@{{ message }}</div>
</body>
</html>
gulpfile.js gulpfile.js
const elixir = require('laravel-elixir');
require('laravel-elixir-vue');
/*
|--------------------------------------------------------------------------
| Elixir Asset Management
|--------------------------------------------------------------------------
|
| Elixir provides a clean, fluent API for defining some basic Gulp tasks
| for your Laravel application. By default, we are compiling the Sass
| file for our application, as well as publishing vendor resources.
|
*/
elixir(function(mix) {
mix.sass('app.scss');
});
elixir(function(mix) {
mix.browserify('app.js');
});
elixir(function(mix) {
mix.version(['css/app.css', 'js/app.js']);
});
am getting an error saying [Vue warn]: Cannot find element: body
出现错误[Vue warn]: Cannot find element: body
any help is appreciated, 任何帮助表示赞赏,
i only see {{message}}
, instead of Hello Vue World when i run it. 运行它时,我只会看到{{message}}
,而不是Hello Vue World。
Followed some tutorial here : https://asked.io/quick-start-guide--laravel-5--vue-js---bootstrap-3 在这里遵循了一些教程: https : //asked.io/quick-start-guide--laravel-5--vue-js---bootstrap-3
Try to put your script tag in the end of the body instead of the head. 尝试将您的脚本标签放在正文的末尾而不是头部。
When the script loads inside the head-tag, the body doesn't exist yet. 当脚本加载到头部标签中时,主体尚不存在。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.