School.vue 668 B

1234567891011121314151617181920212223242526272829303132
  1. <template>
  2. <div class="school">
  3. <h2>学校名称:{{ name }}</h2>
  4. <h2>学校地址:{{ address }}</h2>
  5. <button @click="sendSchoolName">把学校名给App</button>
  6. </div>
  7. </template>
  8. <script>
  9. export default {
  10. name:'School',
  11. props:['getSchoolName'],
  12. data() {
  13. return {
  14. name:'尚硅谷',
  15. address:'北京'
  16. }
  17. },
  18. methods:{
  19. sendSchoolName(){
  20. this.getSchoolName(this.name)
  21. }
  22. }
  23. }
  24. </script>
  25. <style scoped>
  26. .school{
  27. background-color: skyblue;
  28. padding: 5px;
  29. }
  30. </style>