mercredi 13 juillet 2016

How to instantiate a Vue object in jQuery's ready event function?


I want to instantiate a Vue in $(function () {... but failed. Where is the problem?

<script>
$(function){
var vm = new Vue({
        el: '#vm',
        data: {
            a: "I'm a"
        }
     });
     vm.$set('b', "I'm b")
} 
</script>

HTML part:

<html>
<div id="vm">
 <p >{{ a }}</p>
 <p >{{ b }}</p>
</div>
</html>

Here is a test


Aucun commentaire:

Enregistrer un commentaire