<div id="app">
  <h1 ref="message">{{ message }}</h1>
  <button ref="myButton" @click="clickedButton">点击偶</button>
</div>


<div class="skip">
  <a href="https://codepen.io/collection/DRKGbz/" target="_blank">Vue案例全集</a>
</div>
@import url(https://fonts.googleapis.com/css?family=Montserrat);

$colour:hsla(350,100%,25%,1);
$grey:desaturate($colour,90%);

body {
  background:lighten($grey,30%);
    background-image:
    linear-gradient(40deg,transparentize($grey,0.95),transparentize($colour,0.95)),

    linear-gradient(135deg,
        lighten($grey,18%) 0%,
        lighten($grey,18%) 10%,
        lighten($grey,25%) 11%,
        lighten($grey,25%) 40%,
        lighten($grey,35%) 41%,
        lighten($grey,35%) 50%,
        lighten($grey,18%) 51%,
        lighten($grey,18%) 60%,
        lighten($grey,25%) 61%,
        lighten($grey,25%) 90%,
        lighten($grey,35%) 91%)
    ;
    background-size:7px 7px, 4px 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: montserrat;
}

html,body {
  width: 100vw;
  height: 100vh;
}

#app {
  background: white;
	border: 0 none;
	border-radius: 3px;
	box-shadow: 0 0 15px 1px rgba(0, 0, 0, 0.4);
	padding: 20px 30px;
	box-sizing: border-box;
  text-align: center;
}
.title {
  margin: 0 0 25px;
  display: inline-block;
  border-bottom: 2px solid #69f;
  padding-bottom: 5px;
  color: #69f;
  text-shadow: 1px 1px 0 rgba(#000, .4);
}

button {
  color: #454545;
  background: transparent;
  border: 2px solid #454545;
  position: relative;
  margin: 1em .5rem;
  padding: 0.5em 1em;
  transition: all 0.3s ease-in-out;
  text-align: center;
  font-family: comfortaa;
  font-weight: bold;
  font-size: 1.2rem;
  cursor: pointer;
}
button:before, button:after {
  content: '';
  display: block;
  position: absolute;
  border-color: #454545;
  box-sizing: border-box;
  border-style: solid;
  width: 1em;
  height: 1em;
  transition: all 0.3s ease-in-out;
}
button:before {
  top: -6px;
  left: -6px;
  border-width: 2px 0 0 2px;
  z-index: 5;
}
button:after {
  bottom: -6px;
  right: -6px;
  border-width: 0 2px 2px 0;
}
button:hover:before, button:hover:after {
  width: calc(100% + 12px);
  height: calc(100% + 12px);
  border-color: #fff;
}
button:hover {
  color: #353535;
  background-color: #fff;
}
button:active, button:focus {
  outline: none;
}


.skip{
  position: fixed;
  right: 0;
  bottom: 0;
  padding: 10px 30px;
  background: rgba(0,0,0,.5);
  
  a {
    color: #fff;
    text-decoration: none;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, .15);
  }
}
View Compiled
 let app = new Vue({
  el: '#app',
  data () {
    return {
      message: 'Hi!大漠'
    }
  },
  methods: {
    clickedButton: function () {
      console.log(this.$refs);
      this.$refs.myButton.innerText = this.message
    }
  }
})
 
setTimeout(function() {
	app.$refs.message.innerText = '延迟2000ms修改h1元素的文本';
}, 2000);
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

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