其实在摸板中也是可以做简单的计算的,但是会看起来会很乱 ,可以用computed来做计算
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<div id="app">
{{ message }}
{{getAll}}
</div>
</head>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<body>
<script>
var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!',
initDate:2
},
computed:{
getAll:function () { //取一个随便的数来
return this.initDate*2
}
}
})
</script>
</body>
</html>