You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+46-4Lines changed: 46 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,7 +56,7 @@ Now with `lit-html` you can use `.js` and `.ts` extensions:
56
56
```js
57
57
import { html } from'lit-vue'
58
58
59
-
consttemplate=html`
59
+
html`
60
60
<div>
61
61
<h1>hello</h1>
62
62
<hr />
@@ -71,9 +71,6 @@ const template = html`
71
71
`
72
72
73
73
exportdefault {
74
-
// `template` is not necessary here, just to make linter happy
75
-
// Actually its value is always `undefined`
76
-
template,
77
74
data() {
78
75
return {
79
76
count:0
@@ -87,6 +84,51 @@ export default {
87
84
}
88
85
```
89
86
87
+
<details><summary>You might need to configure the ESLint rule: no-unused-expressions</summary><br>
88
+
89
+
ESLint might complain about the the <code>html``</code> expression not being used when you enabled the rule: [no-unused-expressions](http://eslint.cn/docs/rules/no-unused-expressions), there're three ways to solve it:
90
+
91
+
1. Disable this rule for tagged template expression in your ESLint config
You can just assign it to a variable and export it, though the exported variable will never be used. The return value of `html` tag is always undefined.
110
+
111
+
3. Or use it as component option
112
+
113
+
```js
114
+
consttemplate=html`
115
+
<div>{{ count }}</div>
116
+
`
117
+
118
+
exportdefault {
119
+
template,
120
+
data() {
121
+
return {
122
+
count:0
123
+
}
124
+
}
125
+
}
126
+
```
127
+
128
+
Similar to #2, this may look more natural because `template` is a legit Vue component option.
0 commit comments