본문 바로가기

javascript6

<react> TypeError: Cannot read properties of undefined (reading 'setState') 오류 해결 🤔 문제발생 필자가 react에서 setState를 사용하다가 TypeError: Cannot read properties of undefined(reading 'setState') 오류가 브라우저 콘솔창에 나타났다. 이를 해결하기 위해 bind 방법과 화살표 함수를 써야한다. 🎉 해결방법 1 class Lostpassword extends Component { constructor(props) { super(props); this.state = {number :''}; this.plus = this.plus.bind(this); } plus(){ const a = 1; const b = a + a; {this.setState({number:b})} } 첫 번째, this.setState가 있는 함수를 .. 2022. 5. 26.
Component name "파일이름" should always be multi-word vue/multi-word-component-names 오류 해결 방법 Component name "파일이름" should always be multi-word vue/multi-word-component-names의 해결방법은 vue.config.js 파일을 열고 lintOmSave: false 를 추가한다. 2022. 3. 29.
vue project 만드는 방법 1. npm install -g @vue/cli (버전) npm install -g @vue/cli 4.5.11 2. vue.cmd create 프로젝트명 3. vs code 에디터 추가 Vetur html css support Vue3 snippets 2022. 3. 23.
vue router (router -view, router -link) router 설치 npm install vue-router vue router 등록 // 라우터 인스턴스 생성 var router = new VueRouter({ // 라우터 옵션 }) // 인스턴스에 라우터 인스턴스를 등록 new Vue({ router: router }) # vue router 등록은 어디에다가 하는거지? vue router 옵션 routes : 라우팅 할 URL과 컴포넌트 값 지정 mode : URL의 해쉬 값 제거 속성 URL 값이 /login과 /home일 때 각각 로그인 컴포넌트와 홈 컴포넌트를 뿌려준다 new VueRouter({ mode: 'history', routes: [ { path: '/login', component: LoginComponent }, { path: .. 2022. 3. 23.