vue如何将父组件所有的props传递给子组件
vue如何将父组件所有的props一次性传递给子组件
<Child v-bind='$props'></Child>
demo如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <div id="app"> <h2>props细节</h2> <Father name="csx" age=18></Father> </div> <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script> <script> Vue.component('Father',{ props: ['name', 'age'], data(){ return { aa: 'asdfadfad' } }, template: "<Child v-bind='$props'></Child>" }) Vue.component('Child',{ props: ['name', 'age'], template: "<div>child name: {{name}} - age: {{age}}</div>" }) new Vue({ el: '#app' }); </script> </body> </html>