Skip to content

Commit 1692287

Browse files
committed
feat: support <style vars scoped>
1 parent fb09c8b commit 1692287

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

example/ScriptSetup.vue

+12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<h2>{{ hello }}</h2>
33
<div>
44
{{ count }} <button @click="inc">+</button>
5+
<button @click="changeColor">change color</button>
56
<Button/>
67
</div>
78
</template>
@@ -17,4 +18,15 @@ export function inc() {
1718
}
1819
1920
export const hello = 'hi from script setup'
21+
22+
export const color = ref('red')
23+
export const changeColor = () => {
24+
color.value = color.value === 'red' ? 'green' : 'red'
25+
}
2026
</script>
27+
28+
<style scoped vars="{ color }">
29+
h2 {
30+
color: var(--color)
31+
}
32+
</style>

src/stylePostLoader.ts

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const StylePostLoader: webpack.loader.Loader = function(source, inMap) {
1313
id: `data-v-${query.id}`,
1414
map: inMap,
1515
scoped: !!query.scoped,
16+
vars: !!query.vars,
1617
trim: true
1718
})
1819

0 commit comments

Comments
 (0)