{"id":11210,"date":"2025-12-18T12:10:30","date_gmt":"2025-12-18T03:10:30","guid":{"rendered":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=11210"},"modified":"2025-12-18T12:11:42","modified_gmt":"2025-12-18T03:11:42","slug":"11210","status":"publish","type":"post","link":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=11210","title":{"rendered":""},"content":{"rendered":"<h1>Vue.js ref: \ubc18\uc751\ud615 ref vs \ud15c\ud50c\ub9bf ref<\/h1>\n<h2>1. \ubc18\uc751\ud615 ref<\/h2>\n<h3>\ubc18\uc751\ud615 ref\ub780?<\/h3>\n<p>\ubc18\uc751\ud615 ref\ub294 <strong>\ub370\uc774\ud130\ub97c \ubc18\uc751\ud615\uc73c\ub85c \ub9cc\ub4e4\uae30 \uc704\ud55c \ud568\uc218<\/strong>\uc785\ub2c8\ub2e4. \uc8fc\ub85c \uc6d0\uc2dc \ud0c0\uc785(string, number, boolean \ub4f1)\uc744 \ubc18\uc751\ud615\uc73c\ub85c \ub2e4\ub8f0 \ub54c \uc0ac\uc6a9\ud558\uba70, <code>.value<\/code> \uc18d\uc131\uc744 \ud1b5\ud574 \uac12\uc5d0 \uc811\uadfc\ud569\ub2c8\ub2e4.<\/p>\n<h3>\uae30\ubcf8 \uc0ac\uc6a9\ubc95<\/h3>\n<pre><code class=\"language-javascript\">import { ref } from &#039;vue&#039;\n\nexport default {\n  setup() {\n    \/\/ \ub2e4\uc591\ud55c \ud0c0\uc785\uc758 ref \uc0dd\uc131\n    const count = ref(0)\n    const message = ref(&#039;\uc548\ub155\ud558\uc138\uc694&#039;)\n    const isActive = ref(true)\n    const items = ref([])\n    const user = ref({ name: &#039;\ud64d\uae38\ub3d9&#039;, age: 30 })\n\n    \/\/ \uac12 \uc77d\uae30\uc640 \uc218\uc815\n    console.log(count.value) \/\/ 0\n    count.value++ \/\/ 1\n\n    message.value = &#039;\ubc18\uac11\uc2b5\ub2c8\ub2e4&#039;\n    user.value.name = &#039;\uae40\ucca0\uc218&#039;\n\n    return {\n      count,\n      message,\n      isActive,\n      items,\n      user\n    }\n  }\n}<\/code><\/pre>\n<h3>\ud15c\ud50c\ub9bf\uc5d0\uc11c\uc758 \uc790\ub3d9 \uc5b8\ub798\ud551<\/h3>\n<p>\uc2a4\ud06c\ub9bd\ud2b8\uc5d0\uc11c\ub294 <code>.value<\/code>\uac00 \ud544\uc218\uc9c0\ub9cc, \ud15c\ud50c\ub9bf\uc5d0\uc11c\ub294 \uc790\ub3d9\uc73c\ub85c \uc5b8\ub798\ud551\ub429\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-vue\">&lt;template&gt;\n  &lt;div&gt;\n    &lt;!-- .value \uc5c6\uc774 \uc0ac\uc6a9 --&gt;\n    &lt;p&gt;{{ count }}&lt;\/p&gt;\n    &lt;p&gt;{{ message }}&lt;\/p&gt;\n\n    &lt;!-- \uc774\ubca4\ud2b8 \ud578\ub4e4\ub7ec\uc5d0\uc11c\ub3c4 .value \ubd88\ud544\uc694 --&gt;\n    &lt;button @click=&quot;count++&quot;&gt;\uc99d\uac00&lt;\/button&gt;\n\n    &lt;!-- v-model\uc5d0\uc11c\ub3c4 .value \ubd88\ud544\uc694 --&gt;\n    &lt;input v-model=&quot;message&quot;&gt;\n  &lt;\/div&gt;\n&lt;\/template&gt;<\/code><\/pre>\n<h3>\ubc18\uc751\ud615 ref \uc8fc\uc758\uc0ac\ud56d<\/h3>\n<h4>1. \uc2a4\ud06c\ub9bd\ud2b8\uc5d0\uc11c\ub294 \ud56d\uc0c1 .value \uc0ac\uc6a9<\/h4>\n<pre><code class=\"language-javascript\">const count = ref(0)\n\n\/\/ OK\ncount.value = 10\n\n\/\/ \ubc18\uc751\uc131 \uc0c1\uc2e4 : \ub354\uc774\uc0c1 ref \uac1d\uccb4 \uc544\ub2d8\ncount = 10<\/code><\/pre>\n<h4>2. reactive \uac1d\uccb4 \uc548\uc758 ref\ub294 \uc790\ub3d9 \uc5b8\ub798\ud551<\/h4>\n<pre><code class=\"language-javascript\">import { reactive, ref } from &#039;vue&#039;\n\nconst count = ref(0)\nconst state = reactive({\n  count \/\/ reactive \uc548\uc5d0\uc11c\ub294 \uc790\ub3d9 \uc5b8\ub798\ud551\n})\n\nconsole.log(state.count) \/\/ 0 (.value \ubd88\ud544\uc694)\nstate.count++ \/\/ \ub3d9\uc791\ud568<\/code><\/pre>\n<h2>2. \ud15c\ud50c\ub9bf ref<\/h2>\n<h3>\ud15c\ud50c\ub9bf ref\ub780?<\/h3>\n<p>\ud15c\ud50c\ub9bf ref\ub294 <strong>HTML \uc694\uc18c\ub098 \ucef4\ud3ec\ub10c\ud2b8 \uc778\uc2a4\ud134\uc2a4\uc5d0 \uc9c1\uc811 \uc811\uadfc\ud558\uae30 \uc704\ud55c \uae30\ub2a5<\/strong>\uc785\ub2c8\ub2e4.<\/p>\n<h3>\uae30\ubcf8 \uc0ac\uc6a9\ubc95<\/h3>\n<pre><code class=\"language-vue\">&lt;template&gt;\n  &lt;input ref=&quot;emailInput&quot; type=&quot;email&quot; placeholder=&quot;\uc774\uba54\uc77c \uc785\ub825&quot; \/&gt;\n  &lt;button @click=&quot;focusInput&quot;&gt;\ud3ec\ucee4\uc2a4&lt;\/button&gt;\n&lt;\/template&gt;\n\n&lt;script&gt;\nexport default {\n  methods: {\n    focusInput() {\n      \/\/ this.$refs\ub85c DOM \uc694\uc18c \uc811\uadfc\n      this.$refs.emailInput.focus()\n    }\n  },\n  mounted() {\n    console.log(this.$refs.emailInput) \/\/ &lt;input&gt; DOM \uc694\uc18c\n    this.$refs.emailInput.focus() \/\/ \uc790\ub3d9 \ud3ec\ucee4\uc2a4\n  }\n}\n&lt;\/script&gt;<\/code><\/pre>\n<h3>\ud15c\ud50c\ub9bf ref \uc8fc\uc758\uc0ac\ud56d<\/h3>\n<h4>1. \ucd08\uae30\uac12\uc740 null<\/h4>\n<pre><code class=\"language-javascript\">const myInput = ref(null)\n\/\/ \ucef4\ud3ec\ub10c\ud2b8 \ub9c8\uc6b4\ud2b8 \uc804\uae4c\uc9c0 null<\/code><\/pre>\n<h4>2. onMounted\ub098 \uc774\ud6c4\uc5d0 \uc811\uadfc<\/h4>\n<pre><code class=\"language-javascript\">const emailInput = ref(null)\n\n\/\/ setup \ub2e8\uacc4\uc5d0\uc11c\ub294 \uc811\uadfc \ubd88\uac00\nconsole.log(emailInput.value) \/\/ null\n\n\/\/ onMounted\uc5d0\uc11c \uc811\uadfc\nonMounted(() =&gt; {\n  console.log(emailInput.value) \/\/ &lt;input&gt; \uc694\uc18c\n  emailInput.value.focus()\n})<\/code><\/pre>\n<h2>\uc694\uc57d \ube44\uad50\ud45c<\/h2>\n<table>\n<thead>\n<tr>\n<th>\ud2b9\uc9d5<\/th>\n<th>\ubc18\uc751\ud615 ref<\/th>\n<th>\ud15c\ud50c\ub9bf ref<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>\uc120\uc5b8 \ubc29\uc2dd<\/strong><\/td>\n<td><code>const data = ref(value)<\/code><\/td>\n<td><code>&lt;div ref=&quot;name&quot;&gt;<\/code><\/td>\n<\/tr>\n<tr>\n<td><strong>\uc8fc\uc694 \uc6a9\ub3c4<\/strong><\/td>\n<td>\ubc18\uc751\ud615 \uc0c1\ud0dc \uad00\ub9ac<\/td>\n<td>DOM\/\ucef4\ud3ec\ub10c\ud2b8 \uc811\uadfc<\/td>\n<\/tr>\n<tr>\n<td><strong>\uac12\uc758 \ud0c0\uc785<\/strong><\/td>\n<td>\ub370\uc774\ud130 \uac12<\/td>\n<td>DOM \uc694\uc18c \ub610\ub294 \ucef4\ud3ec\ub10c\ud2b8 \uc778\uc2a4\ud134\uc2a4<\/td>\n<\/tr>\n<tr>\n<td><strong>\ucd08\uae30\uac12<\/strong><\/td>\n<td>\uc6d0\ud558\ub294 \uac12<\/td>\n<td><code>null<\/code><\/td>\n<\/tr>\n<tr>\n<td><strong>\uc811\uadfc \uc2dc\uc810<\/strong><\/td>\n<td>\uc989\uc2dc \uac00\ub2a5<\/td>\n<td><code>onMounted<\/code> \uc774\ud6c4<\/td>\n<\/tr>\n<tr>\n<td><strong>\uc2a4\ud06c\ub9bd\ud2b8 \uc0ac\uc6a9<\/strong><\/td>\n<td><code>.value<\/code>\ub85c \uc811\uadfc<\/td>\n<td><code>.value<\/code>\ub85c DOM \uc811\uadfc<\/td>\n<\/tr>\n<tr>\n<td><strong>\ud15c\ud50c\ub9bf \uc0ac\uc6a9<\/strong><\/td>\n<td>\uc790\ub3d9 \uc5b8\ub798\ud551<\/td>\n<td>\uc18d\uc131\uc73c\ub85c\ub9cc \uc0ac\uc6a9<\/td>\n<\/tr>\n<tr>\n<td><strong>\uc8fc\uc694 \uc0ac\ub840<\/strong><\/td>\n<td>\ud3fc \ub370\uc774\ud130, \uc0c1\ud0dc, \uce74\uc6b4\ud130 \ub4f1<\/td>\n<td><code>focus()<\/code>, <code>scroll()<\/code>, \ub77c\uc774\ube0c\ub7ec\ub9ac \uc5f0\ub3d9<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>Vue.js ref: \ubc18\uc751\ud615 ref vs \ud15c\ud50c\ub9bf ref 1. \ubc18\uc751\ud615 ref \ubc18\uc751\ud615 ref\ub780? \ubc18\uc751\ud615 ref\ub294 \ub370\uc774\ud130\ub97c \ubc18\uc751\ud615\uc73c\ub85c \ub9cc\ub4e4\uae30 \uc704\ud55c \ud568\uc218\uc785\ub2c8\ub2e4. \uc8fc\ub85c \uc6d0\uc2dc \ud0c0\uc785(string, number, boolean \ub4f1)\uc744 \ubc18\uc751\ud615\uc73c\ub85c \ub2e4\ub8f0 \ub54c \uc0ac\uc6a9\ud558\uba70, .value \uc18d\uc131\uc744 \ud1b5\ud574 \uac12\uc5d0 \uc811\uadfc\ud569\ub2c8\ub2e4. \uae30\ubcf8 \uc0ac\uc6a9\ubc95 import { ref } from &#039;vue&#039; export default { setup() { \/\/ \ub2e4\uc591\ud55c \ud0c0\uc785\uc758 ref \uc0dd\uc131 const count =\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=11210\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40],"tags":[],"class_list":["post-11210","post","type-post","status-publish","format-standard","hentry","category-language"],"_links":{"self":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/11210","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11210"}],"version-history":[{"count":2,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/11210\/revisions"}],"predecessor-version":[{"id":11212,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/11210\/revisions\/11212"}],"wp:attachment":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11210"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11210"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11210"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}