vuejs2 Props VueJS 2 props example


Example

JavaScript:

Vue.component('props-component', {
    template: '#props-component-template',
    // array of all props
    props: ['myprop', 'calcprop']
});


new Vue({
    el: '#app'
});

HTML:

<div id="app">
    <template id="props-component-template">
        <div>Props: {{myprop}} - {{calcprop}}</div>
    </template>

    <props-component 
        myprop="prop_value" 
        :calcprop="Math.random()">
    </props-component>
</div>