<template> <div class="demo"> <h1>{{ msg}}</h1> <h2>Student name: {{name}}</h2> <h2>Student gender: {{sex}}</h2> <h2>Student's age: {{myage+1}}</h2> <button @click="changeAge">Click me to modify data</button> </div> </template> <script> export default { name: 'Student', data() { return { msg: 'King's Lovers', myage:this.age } }, methods: { changeAge(){ this.myage=24 } }, //Simple reception// props:['name','age','sex'] //Restrict the data type while receiving // props:{ // name:String, //age:Number, // sex:String, // } //While receiving data: limit the type + specify the default value + restrict the necessity props: { name: { type: String, //name type required: true, //name is required}, age: { type: Number, default:22 }, sex: type: String, required: true } } } </script> <template> <div> <Student name="张三" sex="男" :myage="20"/> </div> </template> <script> //Import Student componentimport Student from './components/Student.vue' export default { name: 'App', components: Student } } </script> SummarizeThis article ends here. I hope it can be helpful to you. I also hope that you can pay more attention to more content on 123WORDPRESS.COM! You may also be interested in:
|
<<: Use tomcat to set shared lib to share the same jar
>>: CSS code to distinguish ie8/ie9/ie10/ie11 chrome firefox
IE has had problems for a long time. When everyone...
Table of contents Preface 1. What is phantom read...
Table of contents 2. Stack analysis using pt-pmap...
Preface The reason for writing this article is mai...
1. Introduction When the amount of data in the da...
The meta tag is used to define file information an...
Table of contents Product Requirements Ideas Prob...
Use CSS to prevent Lightbox to realize the displa...
Preface: Lynis is a security audit and hardening ...
This article does not introduce anything related ...
This article is intended to be a starting point f...
mysql row to column, column to row The sentence i...
After the previous two chapters, do you have a ne...
This article mainly introduces the principle and ...
Table of contents Preface 1. Basic knowledge of f...