11 Program to demonstrate Multiple Instances in VueJS

Program:

index.html:

<!DOCTYPE html>
<html>

<body>
    <div id="ad">
        {{ value }}
    </div>

    <div id="demo">
        {{ value }}
        {{ fi() }}
    </div>


    <div style="margin-top:500px;"></div>
    <link rel="stylesheet" type="text/css" href="./style.css">
    <script src="https://unpkg.com/vue"></script>
    <script type="text/javascript" src="./index.js"> </script>

</body>

</html>

index.js:

var app = new Vue({
    el: '#ad',
    data: {
        value: 100,
        price: 2000,
    },
});

var de = new Vue({
    el: '#demo',
    data: { 
        value: 200,
    },
    methods:{
        fi: function(){
            return app.price;
        }
    }
});

Output:

 Multiple Instances in VueJS

Previous
Next Post »