xxx
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
@@ -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)=>{
|
||||
|
||||
Reference in New Issue
Block a user