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

Vue 不会对 $attrs 中的属性中做驼峰转换 #97

Open
yubaoquan opened this issue Jun 6, 2023 · 0 comments
Open

Vue 不会对 $attrs 中的属性中做驼峰转换 #97

yubaoquan opened this issue Jun 6, 2023 · 0 comments

Comments

@yubaoquan
Copy link
Owner

如下例子

父组件:

<attr-test first-name="aaa" last-name="bbb"></attr-test>

子组件

<template>
  <div @click="foo">{{ firstName }} {{ $attrs.lastName }}</div>
</template>

<script>
export default {
  name: 'attr-test',
  props: {
    firstName: String,
  },
  methods: {
    foo() {
      console.info(this.firstName) // aaa
      console.info(this.$attrs.lastName) // undefined
      console.info(this.$attrs['last-name']) // bbb
    }
  }
}
</script>

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

No branches or pull requests

1 participant