<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
</style>
</head>
<body>
<div id="app">
<div>{{msg}}</div>
<div>{{reverseString}}</div>
<div>{{reverseString}}</div>
<div>{{reverseMessage()}}</div>
<div>{{reverseMessage()}}</div>
</div>
<script type="text/javascript" src="./js/vue.js"></script>
<script>
var vm = new Vue({
el: '#app',
data: {
msg: 'Hello',
num: 100
},
methods: {
reverseMessage: function() {
console.log('methods')
return this.msg.split('').reverse().join('')
}
},
computed: {
reverseString: function() {
console.log('computed')
/* return this.msg.split('').reverse().join(''); */
var total = 0;
for (var i = 0; i <= this.num; i++) {
total += i;
}
return total;
}
}
})
</script>
</body>
</html>
标签:vue,methods,前端,36,reverseString,var,msg,reverseMessage,computed From: https://blog.51cto.com/u_15460007/6048830