当前位置: 首页 > 工具软件 > Next.js > 使用案例 >

next.js中组件格式

太叔小云
2023-12-01
import React, { Component } from 'react'
import Link from 'next/link'
import Router from 'next/router'

class you extends Component {
  constructor(props) {
    super(props)
    this.state = {
      title: 'hahah'
    }
  }
  componentWillMount() {
    console.log(222)
  }
  change = () => {
    console.log(1)
    console.log(Router)
    Router.push('/')
  }
  render() {
    return (
      <div className="you">
        <Link href="/">
          <div>to Index</div>
        </Link>
        {this.state.title}
        <button onClick={this.change}>点击啊</button>
      </div>
    )
  }
}
export default you

 

 类似资料: