Banner.vue 593 B

1234567891011121314151617181920212223242526272829
  1. <template>
  2. <div class="col-xs-offset-2 col-xs-8">
  3. <div class="page-header">
  4. <h2>Vue Router Demo</h2>
  5. <button @click="back">后退</button>
  6. <button @click="forward">前进</button>
  7. <button @click="test">测试一下go</button>
  8. </div>
  9. </div>
  10. </template>
  11. <script>
  12. export default {
  13. name:'Banner',
  14. methods: {
  15. back(){
  16. this.$router.back()
  17. // console.log(this.$router)
  18. },
  19. forward(){
  20. this.$router.forward()
  21. },
  22. test(){
  23. // go需要传入一个数字,正数表示前进,负数表示后退
  24. this.$router.go(3)
  25. }
  26. },
  27. }
  28. </script>