Skip to content

Commit f9ccdf9

Browse files
committed
Site updated: 2016-02-06 21:08:51
1 parent 323703b commit f9ccdf9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

2016/02/06/common-gotchas/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ <h3 id="When_is_the_DOM_updated_3F"><a href="#When_is_the_DOM_updated_3F" class=
147147
<h3 id="Why_does_data_need_to_be_a_function_3F"><a href="#Why_does_data_need_to_be_a_function_3F" class="headerlink" title="Why does <code>data</code> need to be a function?"></a>Why does <code>data</code> need to be a function?</h3><p>In the basic examples, we declare the <code>data</code> directly as a plain object. This is because we are creating only a single instance with <code>new Vue()</code>. However, when defining a <strong>component</strong>, <code>data</code> must be declared as a function that returns the initial data object. Why? Because there will be many instances created using the same definition. If we still use a plain object for <code>data</code>, that same object will be <strong>shared by reference</strong> across all instance created! By providing a <code>data</code> function, every time a new instance is created, we can simply call it to return a fresh copy of the initial data.</p>
148148
<p>Further reading: <a href="/guide/components.html#Component_Option_Caveats">Component Option Caveats</a>.</p>
149149
<h3 id="HTML_case_insensitivity"><a href="#HTML_case_insensitivity" class="headerlink" title="HTML case insensitivity"></a>HTML case insensitivity</h3><p>All Vue.js templates are valid, parsable HTML markup, and Vue.js relies on spec-compliant parsers to process its templates. However, as specified in the standard, HTML is case-insensitive when matching tag and attribute names. This means camelCase attributes like <code>:myProp=&quot;123&quot;</code> will be matched as <code>:myprop=&quot;123&quot;</code>. As a rule of thumb, you should use camelCase in JavaScript and kebab-case in templates. For example a prop defined in JavaScript as <code>myProp</code> should be bound in templates as <code>:my-prop</code>.</p>
150-
<p>Further reading <a href="http://vuejs.org/guide/components.html#camelCase_vs-_kebab-case">camelCase vs. kebab-case</a>.</p>
151-
<p>We are also discussing the possibility of eliminating this inconsistency by resolving props and components in a case-insensitive manner as well. Join the conversation <a href="https://github.com/vuejs/vue/issues/2308" target="_blank" rel="external">here</a>.</p>
150+
<p>Further reading: <a href="http://vuejs.org/guide/components.html#camelCase_vs-_kebab-case">camelCase vs. kebab-case</a>.</p>
151+
<p>We are also discussing the possibility of eliminating this inconsistency by resolving props and components in a case-insensitive manner. Join the conversation <a href="https://github.com/vuejs/vue/issues/2308" target="_blank" rel="external">here</a>.</p>
152152

153153
</div>
154154

0 commit comments

Comments
 (0)