Skip to content

Commit b2613ae

Browse files
committed
Refine Vue and Nuxt docs with bidirectional value prop update and hmr note (fixes #173)
1 parent d3e274e commit b2613ae

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

docs/modules-and-frameworks/hljs/nuxt/_index.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ So that the necessary css is loaded for code-input, and an example theme is load
120120

121121
> You might want to replace the second file with your own theme, but you need the first file.
122122
123-
## 3. Initialize the textarea
123+
## 3. Initialize a code-input element
124124

125-
Create a component with whatever name you want. Perhaps `app/components/CodeEditor.vue`. Paste the following into it:
125+
Create a component with whatever name you want. Perhaps `app/components/CodeEditor.vue`. Read the following code then paste it into the file:
126126

127127
```html
128128
<template>
@@ -138,13 +138,14 @@ Create a component with whatever name you want. Perhaps `app/components/CodeEdit
138138
:name="name"
139139
:value="value"
140140
:language="language"
141-
@input="emit('input', elem.value)"
141+
@input="value = elem.value; emit('input', elem.value)"
142142
@code-input_load="loaded"
143143
>
144144
<textarea
145+
ref="fallback"
145146
:name="name"
146147
:value="value"
147-
@input="emit('input', elem.value)"
148+
@input="value = fallback.value; emit('input', fallback.value)"
148149
data-code-input-fallback
149150
></textarea>
150151
</code-input>
@@ -246,3 +247,6 @@ npm run dev
246247
If all went well, you should see the following in the browser:
247248
248249
![An editable syntax-highlighted textarea added to the Nuxt starter page.](nuxt-demo-screenshot.png)
250+
251+
## Please Note
252+
* Hot module replacement (the updating of a running app when files are changed) will not work completely correctly when the `CodeEditor` component is changed but will work when files that use it are changed. This is only important when running a development server.

docs/modules-and-frameworks/hljs/vue/_index.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ vue({
101101

102102
So that Vue knows that `code-input` is not a Vue component.
103103

104-
## 3. Initialize the textarea
104+
## 3. Initialize a code-input element
105105

106-
Create a component with whatever name you want. Perhaps `CodeEditor.vue`. Paste the following into it:
106+
Create a component with whatever name you want. Perhaps `CodeEditor.vue`. Read the following code then paste it into the file:
107107
```html
108108
<template>
109109
<!--Attributes that make sense on a
@@ -118,13 +118,14 @@ Create a component with whatever name you want. Perhaps `CodeEditor.vue`. Paste
118118
:name="name"
119119
:value="value"
120120
:language="language"
121-
@input="emit('input', elem.value)"
121+
@input="value = elem.value; emit('input', elem.value)"
122122
@code-input_load="loaded"
123123
>
124124
<textarea
125+
ref="fallback"
125126
:name="name"
126127
:value="value"
127-
@input="emit('input', elem.value)"
128+
@input="value = fallback.value; emit('input', fallback.value)"
128129
data-code-input-fallback
129130
></textarea>
130131
</code-input>
@@ -227,3 +228,6 @@ npm run dev
227228
If all went well, you should see the following in the browser:
228229

229230
![An editable syntax-highlighted textarea added to the Vue starter page.](vue-demo-screenshot.png)
231+
232+
## Please Note
233+
* Hot module replacement (the updating of a running app when files are changed) will not work completely correctly when the `CodeEditor` component is changed but will work when files that use it are changed. This is only important when running a development server.

0 commit comments

Comments
 (0)