一、從父組件調用子組件的方法React
在React中,父組件可以通過refs來訪問子組件的方法。具體方法如下:
//子組件
class ChildComponent extends React.Component {
sayHello() {
alert("Hello!");
}render() {
return Child Component原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/152140.html
在React中,父組件可以通過refs來訪問子組件的方法。具體方法如下:
//子組件
class ChildComponent extends React.Component {
sayHello() {
alert("Hello!");
}render() {
return Child Component原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/152140.html