I'm successfully getting the object in response. But what I'm not understanding is that , how can I redirect from this particular component to new page.blade.php page ???
Mar 12, 2018
5
Level 1
How can I redirect to a new page using VueJs <router-link> to another blade template.
Hello there, I'm developing a multi page application and what I'm trying to do is that , When I click on the <router-link> I want to go to another page , lets say that page called a SingleCompany.blade.php with the slug of that company,
I'm already in a Header.vue component and want to go the new 'page.blade.php' with one variable.
Here is my Header.vue
<template lang="html">
<div class="main">
<div class="header">
<h1 class="white" style="text-transform:uppercase;">Don't Settle For Average. Relentless moves</h1>
<div class="search-form form-inline">
<div class="input-group" style="width:80%; height:50px; position:relative;">
<span class="input-group-addon" style=""><i class="fa fa-map-marker"></i></span>
<input type="text" class="form-control search-bar" style="box-shadow: inset 0px 1px 6px #0009;" name="search">
</div>
<button type="button" class="btn btn-default search-btn" name="button">Search</button>
</div>
</div>
<div class="cont col-md-12" style="background:#fff; position:relative; z-index:5; top:800px; padding: 30px;">
<div class="col-md-3" v-for="property in properties">
<h3>{{ property.property_title }}</h3>
<div class="img" v-for="image in property.property_has_images">
</div>
</div>
<br>
<div class="row">
<div class="col-md-6">
<h3>Search By Companies</h3>
<ul>
<li v-for="company in companies"><router-link @click.native="getSignleCompany(company.slug)">{{company.company_name}}</router-link></li>
</ul>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
companies: [],
properties: []
}
},
methods: {
getSignleCompany(slug) {
axios.get('/'+slug).then(response => console.log(response)).catch(error => console.log(error));
}
},
created() {
axios.get('/getAllCompanies').then(response => [this.companies = response.data.companies, this.properties = response.data.properties]).catch(error => console.log(error));
}
}
</script>
<style lang="css" scoped>
.header {
background: url('../../images/banner.jpg');
height: 100vh;
width: 100%;
background-size: cover;
background-attachment: fixed;
background-repeat: no-repeat;
background-position: center;
display: grid;
justify-content: center;
align-items: center;
padding: 20px;
position:fixed;
top:0px;
left:0px;
}
.header > h1 {
margin: 0;
padding: 0;
position: relative;
top: 80%;
}
.white{
color: #fff;
margin-bottom:50px;
top:25%;
}
.search-bar
{
height:50px;
border-color:#aaa;
border-radius: 0px;
position:relative;
}
.input-group-addon
{
width:10% !important;
background-color:#fff;
border-radius: 0px
}
.input-group-addon i
{
font-size: 28px;
color:#222;
}
.search-btn
{
width:18%;
height:50px;
background-color:#023544;
border-color:#023544;
font-size:18px;
color:#fff;
border-radius: 0px;
}
@media screen and (max-width: 768px) {
.header > h1 {
position: relative;
top: 70%;
}
}
@media screen and (max-width: 560px) {
.header > h1 {
position: relative;
top: 55%;
}
}
</style>
Please or to participate in this conversation.