index.vue 922 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <template>
  2. <div>
  3. {{counter}}
  4. <hr>
  5. <el-button @click="addFun">add</el-button>
  6. <el-button @click="minFun">min</el-button>
  7. <myChildPage></myChildPage>
  8. </div>
  9. </template>
  10. <script>
  11. import myChildPage from '~/components/test/myChildPage';
  12. import Vue from 'vue';
  13. const myData = Vue.observable({count: 1})
  14. export default {
  15. name: 'test',
  16. provide: {
  17. testData: myData
  18. },
  19. components: {
  20. myChildPage
  21. },
  22. head() {
  23. return {
  24. title: '测试',
  25. meta: [
  26. {
  27. hid: 'description',
  28. name: 'description',
  29. content: '我的测试'
  30. }
  31. ]
  32. }
  33. },
  34. computed: {
  35. counter() {
  36. return myData.count
  37. }
  38. },
  39. methods: {
  40. addFun() {
  41. myData.count++;
  42. },
  43. minFun() {
  44. myData.count--;
  45. },
  46. }
  47. };
  48. </script>
  49. <style scoped>
  50. </style>