一、定义:
①、就是在显示数据之前,对数据进行一些操作转化后再显示。
②、conputed:计算属性写在里面。
<div id="app">
<!-- 不要计算属性 -->
<h2>{{msg1}} {{msg2}}</h2>
<!-- 使用计算属性。代码简洁 -->
<h2>{{fullMsg}}</h2>
</div>
<script src="../js/vue.js"></script>
<script>
const test = new Vue({
el: ‘#app‘,
data: {
msg1: ‘hello‘,
msg2: ‘word‘
},
computed: {
fullMsg() {
return this.msg1 + ‘ ‘ + this.msg2
}
}
})
</script>
原文:https://www.cnblogs.com/wan520/p/14849469.html