有人可以帮助我将方法从父级传递给vue.js中的子组件吗?我一直试图通过将方法作为一个道具来实现它...
我的父组件片段:
methods: {
test: function () {
console.log('from test method')
}
}
<template>
<child-component test="test"><child-component>
</template>
Run Code Online (Sandbox Code Playgroud)
子组件片段
created: {
this.test() //returns test is not a function
},
props: ['test']
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?
提前致谢!
| 归档时间: |
|
| 查看次数: |
14742 次 |
| 最近记录: |