export default {
name : 'ReverseData',
data() {
return {
msg : 'ํด๊ทผ,,ํ๊ณ ์ถ๋ค',
isDone : false,
};
},
computed : {
reversString() {
console.log("computed ์คํํฉ๋๋ค.");
return this.msg.split('').reverse().join('');
}
},
methods : {
changeMsg() {
console.log("method ์คํํฉ๋๋ค.");
if(this.isDone) this.isDone = false;
else this.isDone = true;
}
}
};
</script>
<style>
p {
padding : 10px;
text-align: center;
font-size : 20px;
}
button {
display: block;
margin: 0 auto;
}
console์ ๋ณด๋ฉด methods์ computed๊ฐ ์ถ๋ ฅ๋์๋ค๋ ๋ก๊ทธ๊ฐ ์ฐํ๋ค.
๋ค๋ง, computed๋ ๋ฒํผ์ ์ต์ด๋ก ํด๋ฆญํ์ ๋, ํ ๋ฒ๋ง ์ถ๋ ฅ๋๊ณ
๊ทธ ํ์๋ method๋ง ์ถ๋ ฅ์ด ๋๋ค.
computed๋ ์ฐ๊ฒฐ๋ data๊ฐ์ด ๋ณ๊ฒฝ๋์ง ์์ผ๋ฉด, ํธ์ถํ์ง ์๋๋ค.
computed๋ ์ฐ๊ฒฐ๋ ๋ฐ์ดํฐ ๊ฐ์ด ๋ณ๊ฒฝ๋์์ ๋์, ๊ณ์ฐ์์ ๊ณ์ฐํด์ ์บ์ฑ(๊ฐ์ ์ ์ ์ ์ฅ)ํ์ฌ ๋ฆฌํดํด์ฃผ๋ ์์ฑ
computed๋ ๋ฐ๋์ return๊ฐ์ด ์กด์ฌํด์ผํจ
๋งค๊ฐ๋ณ์๋ฅผ ๋ฐ์ ์ ์์
์ฐ๊ฒฐ๋ data๊ฐ ๋ณ๊ฒฝ๋์์ ๊ฒฝ์ฐ์๋ง ๊ณ์ฐ
methods
๋ช ์์ ์ผ๋ก ํธ์ถ๋ ๋์ ์คํ
๋งค๊ฐ๋ณ์๋ฅผ ๋ฐ์ ์ ์์
'๐ Language > Vue' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Vue] ๋ผ์ฐํฐ(Router) ๋ฐฉ์ (Nested Routers, Named Views) (0) | 2022.05.04 |
---|---|
[Vue] ๋ผ์ฐํฐ(Router) (0) | 2022.05.04 |
[Age of Vue] Vue.js ์์ํ๊ธฐ - 17. ๋ทฐ ์ธ์คํด์ค์์ this (0) | 2022.05.02 |
[Age of Vue] Vue.js ์์ํ๊ธฐ - 16. event emit (0) | 2022.05.02 |
[Age of Vue] Vue.js ์์ํ๊ธฐ - 15.props ์ค์ต (0) | 2022.05.02 |