vue组件3-父子组件props传参

xiaoxiao2021-02-28  82

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>父子组件传参-props</title> </head> <script src="vue.js"></script> <body> <div id="app1"> <parent></parent> </div> <script> Vue.component('child', { // 声明 props props: ['message'], template: '<span>{{ message }}</span>' }) //父子组件props传参子组件中可以使用props:['myMessage'],在父组件引用子组件时,使用my-message ="xx" Vue.component('parent',{     template:'<div><child message="我是子元素"></child></div>' }) new Vue({     el:"#app1" }) </script> </body> </html>
转载请注明原文地址: https://www.6miu.com/read-56244.html

最新回复(0)