본문 바로가기
vue.js

뷰 인스턴스에서의 this

by 신방동불주먹 2023. 1. 11.
반응형
  • this 는 obj 즉 해당 객체를 바라본다. 
var obj ={
	num : 10,
    getNumber : function(){
    	console.log(this.num);
        }
    }

 

 

  • 즉 여기서 this.num 은 Vue객체를 바라봄
var Vue = {
	el: '',
    data: {
    	num: 10,
    },
    method:{
    	getNumber:function(){
        	this.num
            }
     },
  }

 

- 참고

 

 

JavaScript this

W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

www.w3schools.com

https://betterprogramming.pub/understanding-the-this-keyword-in-javascript-cb76d4c7c5e8

반응형

'vue.js' 카테고리의 다른 글

뷰 라우터  (0) 2023.04.19
같은 컴포넌트 레벨간의 통신  (0) 2023.01.11
컴포넌트 통신 - event emit  (0) 2023.01.11
컴포넌트 통신 - props  (0) 2023.01.10
컴포넌트  (0) 2023.01.10