I want to make a connection to another view and use the parameters of the first view in the
landig page: video_populares.vue
with vue.js + rails, but I am confused by the examples that I find do not use for meters of an API, I will be grateful if you can help me, this is the code:
popular_vue.js:
import Vue from 'vue'
import Popular from './popular.vue'
document.addEventListener('DOMContentLoaded', () => {
document.body.appendChild(document.createElement('popular'))
const popular = new Vue(Popular).$mount('popular')
// console.log(app)
})
popular.vue:
template with http service call with axios and inserted in the template are video name and image
<div v-for="nota in notas_p">
<div class="col-sm-3 post post-6">
<div class=" m0 inner">
<div class=" m0 featured_img">
<a href="#"><img v-bind:src="nota.image_url" alt=""></a>
</div>
<div class=" m0 post_contents">
<div class="m0 category sports">
</div>
<h3 class="post_title">
<a href="#">{{nota.name}}</a>
</h3>
<ul class="post_meta nav nav-pills">
<li></li>
</ul>
</div>
</div>
</div>
<script>
export default {
data: {
notas_p: []
},
mounted() {
axios.get("xxxxxxx")
.then(response => {
this.notas_p = response.data
})
}
}
</script>
second view video_populares_vue.js:
import Vue from 'vue'
import Video_populares from './video_populares.vue'
document.addEventListener('DOMContentLoaded', () => {
document.body.appendChild(document.createElement('video_populares'))
const video_populares = new Vue(Video_populares).$mount('video_populares')
})
video_populares.vue:
in this view, the data from the previous view will be printed when the transition is made.
<div class="col-sm-12 post interview">
<div class="row m0 featured_img">
<div class="video">
<iframe width="640" height="360" src="#" frameborder="0" allowfullscreen></iframe>
</div>
</div>
</div>
<script>
export default {
data: {
notas_p: []
},
mounted() {
axios.get("xxxxxx")
.then(response => {
this.notas_p = response.data
})
}
}
</script>
routas en rails:
root 'pages#index'
get 'pages/index'
get 'programs/index'
get 'programs/show'