Skip to content
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

$refs #2139

Closed
xjh1230 opened this issue Sep 17, 2020 · 3 comments
Closed

$refs #2139

xjh1230 opened this issue Sep 17, 2020 · 3 comments

Comments

@xjh1230
Copy link

xjh1230 commented Sep 17, 2020

What problem does this feature solve?

why refs value changed from array(vue2) to single(vue3)

What does the proposed API look like?

why refs value changed from array(vue2) to single(vue3)

@dnlsndr
Copy link

dnlsndr commented Sep 17, 2020

What is your issue? Provide some more explaination or examples please?

@xjh1230
Copy link
Author

xjh1230 commented Sep 17, 2020

in vue2 $refs.items is [li#1, li#2, li#3]

<div id="app">
    <ul>
        <li ref="items" v-for="item in items" :id="item" :key="item">{{item}}</li>
    </ul>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
    var app = new Vue({
    el: '#app',
    data: {
        message: 'Hello Vue!',
        items:[1,2,3]
    },
    mounted: function () {
        console.log(this.$refs.items) //[li#1, li#2, li#3]
    }
    })
</script>

in vue3 $refs.items is li#3

<div id="app">
    <ul >
        <li ref="items" v-for="item in items" :id="item" :key="item">{{item}}</li>
    </ul>
</div>
<script src="https://unpkg.com/vue@next"></script>
<script>
  const app = Vue.createApp({
        data() {
            return {
                items:[1,2,3]
            }
        },
        mounted: function () {
                console.log(this.$refs.items) // <li id="3"></li>
        }
    })
    app.mount('#app')
</script>

@RobbinBaauw
Copy link
Contributor

See #1166

@posva posva closed this as completed Sep 17, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Nov 4, 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

4 participants