<div id="app">
  <div v-if="show">
    用户名:<input type="text">
  </div>
  <div v-else>
    密码:<input type="text">
  </div>
  <button @click="btnClick">切换</button>
</div>
var app = new Vue({
  el: "#app",
  data: {
    show: true
  },
  methods: {
    btnClick: function () {
      this.show = !this.show;
    }
  }
});

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