I'm super newbie in vuejs. I don't know how to pass props component to root instance
Here is my code.
component (Tesvue.vue)
<template>
<label class="col-md-2 control-label">{{name}}</label>
</template>
<script>
export default {
props: ['name']
}
</script>
Root (app.js)
window.Vue = require('vue');
import tesvue from './components/Tesvue.vue';
var vm = new Vue({
el: '#app',
components: {
tesvue
},
data:{
getname: ''
}
});
blade file
<div class="" id="app">
<tesvue name="{{$model->name}}"></tesvue>
</div>
The scenario is, im fetching data from laravel controller to blade element, then vue js can access it. This is like pass php variable to vuejs.
I know this can be done with Php-vars-to-javascript plugin, or i can simply use it inline. like this
var name = {{name}}
but i want do that in vuejs way (props).
So how to pass props data to root instance. How 'getname' can get props 'name'
Thanks, sorry my bad english.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…