Skip to content

local scope,Simplify the template, and Reduce function run that some function with args #1438

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

Closed
zhangenming opened this issue Jun 24, 2020 · 3 comments

Comments

@zhangenming
Copy link
Contributor

What problem does this feature solve?

<div v-for="a in 2" :key="a">
      <div v-for="b in 3" :key="b">
        <span>{{func(a.b).field1}}</span>
        <span>{{func(a.b).field2}}</span>
        <span>{{func(a.b).field3}}</span>
        <span>{{func(a.b).field4}}</span>
      </div>
</div>

What does the proposed API look like?

<div v-for="a in 2" :key="a">
      <div v-for="b in 3" :key="b">
          {{const tmp = func(a.b) //such a way like this}}
        <span>{{tmp.field1}}</span>
        <span>{{tmp.field2}}</span>
        <span>{{tmp.field3}}</span>
      </div>
</div>
@posva
Copy link
Member

posva commented Jun 24, 2020

Prior art: vuejs/vue#6913

This should go through an RFC process. It would probably be useful to have in-template computed properties as well. I created this for vue 2 https://github.com/posva/vue-local-scope

@zhangenming
Copy link
Contributor Author

zhangenming commented Jun 28, 2020

微信图片_20200628234542
now i get a hack very useful
like :justAHack="(SUDUKO = gene([S, I]), '')"

@yyx990803
Copy link
Member

This is something that we'd like to find a good solution for but it should probably go through the RFC process instead of being discussed here.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants