image.png

    1. <template>
    2. <div>
    3. <h1>{{msg}}</h1>
    4. <h2>名字{{name}}</h2>
    5. <h2>性别{{sex}}</h2>
    6. <h2>年冷{{myage}}</h2>
    7. <button @click="change">修改</button>
    8. </div>
    9. </template>
    10. <script>
    11. export default {
    12. name:'Student',
    13. data(){
    14. console.log(this)
    15. return{
    16. msg:'我是一个学生',
    17. myage:this.age
    18. }
    19. },
    20. methods:{
    21. change(){
    22. this.myage++
    23. }
    24. },
    25. props:{
    26. name:{
    27. type:String,
    28. required:true
    29. },
    30. age:{
    31. type:Number
    32. // require:true,
    33. // default:99
    34. },
    35. sex:{
    36. type:String,
    37. required:true
    38. }
    39. }
    40. }
    41. </script>
    42. <style>
    43. </style>
    1. <template>
    2. <div id="app">
    3. <!-- <img alt="Vue logo" src="./assets/logo.png"> -->
    4. <!-- <HelloWorld msg="Welcome to Your Vue.js App"/> -->
    5. <h2 v-text="mas" ref="title"></h2>
    6. <button ref="btn" @click="clickof">点我输出dom</button>
    7. <school></school>
    8. <student name="李四" :age="12" sex="nv"></student>
    9. </div>
    10. </template>
    11. <script>
    12. // import HelloWorld from './components/HelloWorld.vue'
    13. import School from './components/School.vue'
    14. import Student from './components/Student.vue'
    15. export default {
    16. name: 'App',
    17. data(){
    18. return {
    19. mas:"aaaa"
    20. }
    21. },
    22. components: {
    23. // HelloWorld
    24. School,
    25. Student
    26. },
    27. methods:{
    28. clickof(){
    29. console.log(this.$refs)
    30. }
    31. }
    32. }
    33. </script>
    34. <style>
    35. #app {
    36. font-family: Avenir, Helvetica, Arial, sans-serif;
    37. -webkit-font-smoothing: antialiased;
    38. -moz-osx-font-smoothing: grayscale;
    39. text-align: center;
    40. color: #2c3e50;
    41. margin-top: 60px;
    42. }
    43. </style>