tailwindcss + next.색인 DB용 CRUD 생성
14903 단어 CSSNext.jsNode.jsTailwind CSStech
요약:
tailwindcss + next.색인 DB용 CRUD 생성
컨디션
프레젠테이션 페이지 참조
https://cms-kuc-jamstack-ex14.netlify.app/
참조 코드
create.js
export default class extends Component {
constructor(props){
super(props)
this.state = {title: '', content: ''}
this.handleClick = this.handleClick.bind(this);
//console.log(props)
}
componentDidMount(){
var config = LibTask.get_const()
this.db = new Dexie( config.DB_NAME );
this.db.version(config.DB_VERSION).stores( config.DB_STORE );
}
handleChangeTitle(e){
this.setState({title: e.target.value})
}
handleChangeContent(e){
this.setState({content: e.target.value})
}
handleClick(){
this.add_item()
}
async add_item(){
try {
var item = {
title: this.state.title,
content: this.state.content,
created_at: new Date(),
}
// console.log(item)
await this.db.tasks.add( item )
Router.push('/tasks');
} catch (error) {
console.error(error);
}
}
render() {
return (
<div className="bg-gray-100">
<Layout>
<div className="container mx-auto px-5 py-4 bg-white">
<Link href="/tasks">
<a className="btn-outline-blue my-2">Back</a>
</Link>
<h1 className="text-5xl font-bold my-4">Tasks - Create
</h1>
<hr className="my-2" />
<div className="w-full max-w-md">
<label>Title:</label>
<input className="input_text_gray my-2" type="text" placeholder="Name123"
onChange={this.handleChangeTitle.bind(this)} />
<hr className="my-2" />
<label>Content:</label>
<textarea className="input_textarea_gray my-2"
rows="8"
onChange={this.handleChangeContent.bind(this)}></textarea>
</div>
<div className="form-group">
<button className="btn-blue" onClick={this.handleClick}>Create
</button>
</div>
<hr />
</div>
</Layout>
</div>
)
}
}
참조 페이지
....
Reference
이 문제에 관하여(tailwindcss + next.색인 DB용 CRUD 생성), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://zenn.dev/knaka0209/articles/8f7cd38f8a29fb텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)