This commit is contained in:
XTT-20201225UUE\Administrator
2021-06-16 20:35:05 +08:00
parent 8b13e565be
commit 277a5aa41e
3 changed files with 20 additions and 1 deletions
+3
View File
@@ -2,6 +2,7 @@ import logo from './logo.svg';
import './App.css';
import React from 'react'
import Nav from './components/nav'
import Slot from './components/button'
class App extends React.Component{
constructor(){
super();
@@ -32,6 +33,8 @@ class App extends React.Component{
<p>
{this.state.childValue}
</p>
<Slot type="button">普通按钮</Slot>
<Slot type="submit">提交按钮</Slot>
<a
className="App-link"
href="https://reactjs.org"
+16 -1
View File
@@ -1 +1,16 @@
import React ,{component} from 'react'
import React ,{Component} from 'react'
export default class Button extends Component {
render(){
return(
<React.Fragment>
<button type={this.props.type}>
{this.props.children}
</button>
</React.Fragment>
)
}
}
Button.defaultProps={
type:'button'
}
+1
View File
@@ -7,6 +7,7 @@ class Nav extends Component{
<h3>2、子组件向父组件传值</h3>
<h3>3、遍历</h3>
<h3>4、插槽</h3>
<h3>5、props默认值</h3>
<div>
{
this.props.goods.map((item,index)=>{