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

Warn when key, ref or slot are declared in props #4241

Closed
dongyang03 opened this issue Nov 18, 2016 · 2 comments
Closed

Warn when key, ref or slot are declared in props #4241

dongyang03 opened this issue Nov 18, 2016 · 2 comments

Comments

@dongyang03
Copy link

<div id="app">
  <demo key="key1"></demo>
</div>
</body>
<script>
    import Vue from 'vue';
    import demo from '../demo.vue';
    new Vue({
        el: '#app',
        components: {
           demo
        }
    })
</script>

//demo components

<template>
     <div>test demo</div>
</template>
<script>
    export default{
        props: {
            key:String
        },
        created(){
            console.log(this.key);  //print undefined
        }
    }
</script>
@simplesmiler
Copy link
Member

The key is a special attribute, along with ref and slot. You can not use them as prop names.
However I think Vue should give a warning when you try to declare them as props.

@simplesmiler simplesmiler changed the title props key is undefined Warn when key, ref or slot are declared in props Nov 18, 2016
@dongyang03
Copy link
Author

@simplesmiler thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants