@@ -57,11 +57,13 @@ Now with `lit-html` you can use `.js` and `.ts` extensions:
57
57
import { html } from ' lit-vue'
58
58
59
59
html `
60
- <div >
61
- <h1 >hello</h1 >
62
- <hr />
63
- <button @click =" inc" >{{ count }}</button >
64
- </div >
60
+ <template >
61
+ <div >
62
+ <h1 >hello</h1 >
63
+ <hr />
64
+ <button @click =" inc" >{{ count }}</button >
65
+ </div >
66
+ </template >
65
67
66
68
<style scoped >
67
69
h1 {
@@ -102,7 +104,9 @@ ESLint might complain about the the <code>html``</code> expression not
102
104
103
105
``` js
104
106
export const template = html `
105
- <div >{{ count }}</div >
107
+ <template >
108
+ <div >{{ count }}</div >
109
+ </template >
106
110
`
107
111
```
108
112
@@ -112,7 +116,9 @@ You can just assign it to a variable and export it, though the exported variable
112
116
113
117
``` js
114
118
const template = html `
115
- <div >{{ count }}</div >
119
+ <template >
120
+ <div >{{ count }}</div >
121
+ </template >
116
122
`
117
123
118
124
export default {
@@ -165,24 +171,59 @@ module.exports = {
165
171
166
172
That's it, [ all the goodies] ( https://vue-loader.vuejs.org/ ) of ` .vue ` SFC are available in your ` .vue.js ` and ` .vue.ts ` files now!
167
173
168
- ### Custom blocks
174
+ ### Optional ` <template> ` element
169
175
170
- You can also use [ custom blocks ] ( https://vue-loader.vuejs.org/guide/custom-blocks.html ) in the ` html ` tag :
176
+ ` <template> ` inside ` html ` is optional :
171
177
172
178
``` js
173
179
html `
174
- <custom-block name =" i18n" > { "en": {} } </custom-block >
180
+ <h1 >hello</h1 >
181
+ `
182
+
183
+ // or
184
+
185
+ html `
186
+ <template >
187
+ <h1 >hello</h1 >
188
+ </template >
175
189
`
176
190
```
177
191
178
- It will be converted to :
192
+ When using templates without ` <template> ` tag, you have to use ` <custom-block> ` element to define custom blocks :
179
193
180
- ``` vue
181
- <i18n>
182
- {
183
- "en": {}
194
+ ``` js
195
+ html `
196
+ <h1 >hello</h1 >
197
+
198
+ <custom-block name =" i18n" > {"en": {}} </custom-block >
199
+ `
200
+
201
+ // or
202
+
203
+ html `
204
+ <template >
205
+ <h1 >hello</h1 >
206
+ </template >
207
+
208
+ <i18n > {"en": {}} </i18n >
209
+ `
210
+ ```
211
+
212
+ And in fact even the whole Vue template is optional in ` html ` tag, you can just use ` <style> ` and custom blocks with render function instead:
213
+
214
+ ``` js
215
+ html `
216
+ <style scoped lang =" sass" >
217
+ h1
218
+ color: red
219
+ </style >
220
+ `
221
+
222
+ export default {
223
+ render (h ) {
224
+ return h ('h 1', null , ['hello '])
225
+ }
184
226
}
185
- </i18n>
186
227
```
187
228
188
229
### Syntax higlighting
0 commit comments