-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: v-scope #7218
base: main
Are you sure you want to change the base?
feat: v-scope #7218
Conversation
3242944
to
69d2638
Compare
It's great! I'd like to migrate it to Vue Macros for early experience. |
❌ Deploy Preview for vuejs-coverage failed.
|
This is a good idea, but the pure string method is not very friendly. Maybe we can? <h1 v-let.a="msg + ` Vue`">{{ a }}</h1> |
Shall we align the design with petite-vue (which uses |
Excellent advice. I will try it later. |
How is this PR now? Really really really want to use |
Is it possible to define |
2625719
to
673a645
Compare
Hi @edison1105, sorry to bug you ~ I want to ask, is there any timeline about when will this PR be merged? |
I care about this feature, because I recently taught a friend frontend programming. He know a little js, but almost had no experience about html, css and reactive programming. We used alpinejs for the teaching. With alpine's But actually, we want to use vue, because alpine has no good component support. This is why I care about this feature :) Wish |
@xieyuheng |
Will the language server be updated to integrate |
I found that I can use component to do the following:
<script setup lang="ts">
import { reactive } from 'vue'
defineProps<{ scope: any }>()
</script>
<template>
<slot :scope="reactive(scope)" />
</template>
<Scope :scope="{ count: 1 }" v-slot="{ scope }">
<div>{{ scope.count }}</div>
<button @click="scope.count++">add1</button>
</Scope> |
yep, mentioned in #7201 (comment) |
Not sure |
@xieyuheng // Scope/index.vue
<script setup lang="ts">
import { reactive } from 'vue'
</script>
<template>
<slot :="(reactive($attrs) as any)" />
</template> // ForExampleMemoryStat/index.vue
<script lang="ts" setup>
import Scope from '@/shared/components/Scope/index.vue'
import { MemoryInfo, useMemory } from '@vueuse/core'
const { isSupported, memory } = useMemory()
const getBToMbString = (kb: number) => `${Math.ceil(kb / 1024 / 1024)} MB`
</script>
<template>
<Scope
v-if="isSupported && memory"
:="memory"
v-slot="{
usedJSHeapSize,
jsHeapSizeLimit,
totalJSHeapSize,
}: MemoryInfo"
>
<div class="grid grid-cols-2 grid-gap">
<div>usedJSHeapSize</div>
<div>{{ getBToMbString(usedJSHeapSize) }}</div>
</div>
<div class="grid grid-cols-2 grid-gap">
<div>totalJSHeapSize</div>
<div>{{ getBToMbString(totalJSHeapSize) }}</div>
</div>
<div class="grid grid-cols-2 grid-gap">
<div>jsHeapSizeLimit</div>
<div>{{ getBToMbString(jsHeapSizeLimit) }}</div>
</div>
</Scope>
</template> Instead of // ForExampleMemoryStat/index.vue
<script lang="ts" setup>
import { useMemory } from '@vueuse/core'
const { isSupported, memory } = useMemory()
const getBToMbString = (kb: number) => `${Math.ceil(kb / 1024 / 1024)} MB`
</script>
<template>
<template v-if="isSupported && memory">
<div class="grid grid-cols-2 grid-gap">
<div>usedJSHeapSize</div>
<div>{{ getBToMbString(memory.usedJSHeapSize) }}</div>
</div>
<div class="grid grid-cols-2 grid-gap">
<div>totalJSHeapSize</div>
<div>{{ getBToMbString(memory.totalJSHeapSize) }}</div>
</div>
<div class="grid grid-cols-2 grid-gap">
<div>jsHeapSizeLimit</div>
<div>{{ getBToMbString(memory.jsHeapSizeLimit) }}</div>
</div>
</template>
</template> Of course, I understand that in this example the benefit is dubious in brevity. However, it may be useful to someone and in other scenarios it will be justified. |
Size ReportBundles
Usages
|
I'm glad this feature is coming |
I think I have a playground that demonstrates what I mean here. |
@louiss0 |
Please consider doing this change there is no point in being able to declare variables in the template with random tags. It makes code soo confusing! |
@louiss0 That could be a replacement for |
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
rfc: vuejs/rfcs#73
close #7201
playground