The example in this article analyzes the properties of Props in Vue for your reference. The specific content is as follows
Use Props to transfer data
The scope of the component instance is isolated. This means that the parent component's data cannot and should not be referenced directly within the child component's template. You can use props to pass data to child components.
"prop" is a field of component data that is expected to be passed down from the parent component. Child components need to explicitly declare props with the props option:
Vue.component('child', { // 声明 props props: ['msg'], // prop 可以用在模板内 // 可以用 `this.msg` 设置 template: '<span>{{ msg }}</span>' })
and then pass it a normal string:
Example
Incorrect way of writing:
<!DOCTYPE html> <html lang="en"> <head> <script type="text/javascript" src="./vue.js"></script> <meta charset="UTF-8"> <title>vue.js</title> </head> <body> <pre class="brush:php;toolbar:false"> //使用 props 传输资料予子组件 //props , data 重复名称会出现错误