<div id="app">
<p>{{ message }}</p>
<input type="text" v-model="message"></input> <!--可以同时绑定p和input-->
<button v-on:click="reverseMessage">反转字符串</button>
</div>
<script>
new Vue({
el: '#app',
data: {
message: 'Runoob!'
},
methods: {
reverseMessage: function () {
this.message = this.message.split('').reverse().join('')
}
}
})
</script>