Siguiendo un tuto de vue <3

This commit is contained in:
Daniel Cortés
2019-06-16 17:37:08 -04:00
parent d5ff988b08
commit 2f09a63357
9 changed files with 70 additions and 41 deletions

View File

@@ -0,0 +1,13 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class SpaController extends Controller
{
public function index()
{
return view('spa');
}
}

5
package-lock.json generated
View File

@@ -8891,6 +8891,11 @@
"vue-style-loader": "^4.1.0" "vue-style-loader": "^4.1.0"
} }
}, },
"vue-router": {
"version": "3.0.6",
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.0.6.tgz",
"integrity": "sha512-Ox0ciFLswtSGRTHYhGvx2L44sVbTPNS+uD2kRISuo8B39Y79rOo0Kw0hzupTmiVtftQYCZl87mwldhh2L9Aquw=="
},
"vue-style-loader": { "vue-style-loader": {
"version": "4.1.2", "version": "4.1.2",
"resolved": "https://registry.npmjs.org/vue-style-loader/-/vue-style-loader-4.1.2.tgz", "resolved": "https://registry.npmjs.org/vue-style-loader/-/vue-style-loader-4.1.2.tgz",

View File

@@ -22,5 +22,8 @@
"sass-loader": "^7.1.0", "sass-loader": "^7.1.0",
"vue": "^2.5.17", "vue": "^2.5.17",
"vue-template-compiler": "^2.6.10" "vue-template-compiler": "^2.6.10"
},
"dependencies": {
"vue-router": "^3.0.6"
} }
} }

48
resources/js/app.js vendored
View File

@@ -1,32 +1,30 @@
/** import Vue from 'vue'
* First we will load all of this project's JavaScript dependencies which import VueRouter from 'vue-router'
* includes Vue and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel.
*/
require('./bootstrap'); Vue.Use(VueRouter)
window.Vue = require('vue'); import App from './views/App'
import Hello from './views/Hello'
import Home from './views/Home'
/** const router = VueRouter({
* The following block of code may be used to automatically register your mode: 'history',
* Vue components. It will recursively scan this directory for the Vue routes: [
* components and automatically register them with their "basename". {
* path: '/',
* Eg. ./components/ExampleComponent.vue -> <example-component></example-component> name: 'home',
*/ component: Home
},
// const files = require.context('./', true, /\.vue$/i); {
// files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default)); path: '/hello',
name: 'hello',
Vue.component('example-component', require('./components/ExampleComponent.vue').default); component: Hello
},
/** ],
* Next, we will create a fresh Vue application instance and attach it to });
* the page. Then, you may begin adding components to this application
* or customize the JavaScript scaffolding to fit your unique needs.
*/
const app = new Vue({ const app = new Vue({
el: '#app', el: '#app',
components: { App },
router,
}); });

View File

@@ -0,0 +1,15 @@
<template>
<div>
<h1>Vue Router Demo App</h1>
</div>
<p>
<router-link :to="{ name: 'home' }">Home</router-link>
<router-link :to="{ name: 'hello' }">Hello World</router-link>
</p>
<div class="container">
<router-view></router-view>
</div>
</template>
<script>
export default {}
</script>

View File

@@ -0,0 +1,3 @@
<template>
<p>Hello!</p>
</template>

View File

@@ -0,0 +1,3 @@
<template>
<p>This is the homepage</p>
</template>

View File

@@ -3,12 +3,14 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>Laravel</title> <meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Spa!</title>
</head> </head>
<body> <body>
<div id="app"> <div id="app">
<example-component></example-component> <app></app>
</div> </div>
<script src="{{ mix('js/app.js') }}"></script> <script src="{{ mix('js/app.js') }}"></script>
</body> </body>
</html> </html>

View File

@@ -1,16 +1,3 @@
<?php <?php
/* Route::get('/{any}', 'SpaController@index')->where('any', '.*');
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('welcome');
});