<div id="app">
  {{fullName()}}
  {{age}}
  <hr>
  <button @click="count">方法,当计算的内容没有发生变化时,页面重新渲染的时候会重新进行计算渲染该元素/控制台会在每次改变的时候打印1次</button>
</div>
var app = new Vue({
  el: "#app",
  data: {
    firstName: "xiao",
    lastName: "dongxier",
    age: "28"
  },
  methods: {
    fullName: function () {
      console.log("计算了1次");
      return this.firstName + " " + this.lastName;
    },
    count: function () {
      this.age++;
    }
  }
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/vue/2.7.8/vue.min.js