处理原数据,便于进行二次利用。( 比如:消费税自动计算功能)
<!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">
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<title>Document</title>
</head>
<body>
<div id = "myApp">
任天堂发布的新主机价格是:{{prcie}}元,含税价格为{{priceInTax}}元,折合人名币为:{{priceChinaRMB}}元
</div>
<script>
var myApp = new Vue({
el:"#myApp",
data:{
price:29980
},
computed:{
priceInTax:function(){
return this.price * 1.08;
},
priceChinaRMB:function(){
return Math.round(this.priceInTax / 16.75);
},
},
});
</script>
</body>
</html>