vue model双向绑定

view

<div id='demo' class="container">
<input type="text" v-model='name'> <pre> {{ $data | json }}</pre>
</div>

js

new Vue({
el: '#demo', data: {
name: 'foobar'
}
});

显示

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAATMAAABoCAIAAAASBICJAAAF1UlEQVR4nO3cQW6jOhzH8bmTDxTlKCxyD1Ycg112Vek2vMWTPNKTOhppmqposstbpIANNoZA4Z/6+9FI0xIDxvEPG0L64xqif/4KlsEj+uff/7auArx+BEuQzO+KZEpGMuNFMiUjmV9Fa711FQJIpmQTk3k8KKWUUvtsarc7HpQ6HCeuJGj7I+twaxid7e9oorWRTMmmJXNG948hmQ2SibkmJLMeL1UdAZ3t6wVWN3QuPx6UOmTNK0aIjOLGCzrb77Ps4B6hm1W82zdWcW//eFD77Ogq3x7orQJNVX3Ha664z7RRTMypwolkSnb3mKmzvdXN687qW37r7v2VrbHueLBj7w3ArZA5NFnb7+zXtf2h8uahmPVpquMZE5nNYjH3JlNne2tEqF/xLe/ONj2TT3sHgWAOLPXNbdvlnvJNuK51JZzV7x1nvRWSiWXcm0y7B7d90be8+0Kn7xozZU/0fWv2q9b/zbV9d/mhE05PrxYkE4vZPJlH61LSPyj317T5kunb/vRkhqNGMrGYrWezncCOSOa02ax3+zNns04kE4vZ5g5Qu9zs8Z9TxrZze6LgjK8/ae7t+8ZY310l+46UcWB2xUgmljHn88ypn5oYn1K4LzEPR/u+q3eQavdg3XZ1Xmd6tj9wXWp/atJW1bzYdOauHXCt27pSkUzJeDpvUPey+VshmZKRTJs1TX2MSendSKZkJLMrOGf9NkimZCQzXiRTMpIZL5IpGcmMF8mUbFQyX3+/rVAVrOn19xvJlCyczI+Pvz9f//Dv+/37+Pi7Qg/DfcLJvF6vl8ulLMuiKJ4ArCKczMvl8vLyorV+e3urAKwinMyyLLXWW9cTiEs4mUVRnM/nresJxCWczKenp60rCUSHZAISkUxAIpIJSEQyAYlIJiARyQQkIpmARCQTkIhkAhKRTECiGJOZJ0oppZJ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Vue({
el: '#demo', data: {
name: 'foobar'
}, ready:function(){
var that = this; setInterval(function(){
that.name = 'Updated';
}, 5000);
}
});
上一篇:Linux 内核版本命名


下一篇:趣拍SDK接入问题Android