search

Home  >  Q&A  >  body text

javascript - vue2.0中,$refs对象为什么用驼峰的方式获取不到属性?

阿神阿神2786 days ago648

reply all(2)I'll reply

  • 巴扎黑

    巴扎黑2017-04-17 16:39:42

    The key of

    ref is the same as the key you filled in. It will not be automatically converted into camel case. If you want to use camel case, just use ref="camelCase" and it will be fine

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 16:39:42

    HTML features are not case sensitive. Therefore, when using a template other than a string template, camelCased (camel case) named props need to be converted to the corresponding kebab-case (dash separated) names:

    <child my-message="hello!"></child>

    What needs kebab-case is the html feature prop, not the value you bind later. You have bound the 'menu-wrapper' name to the ref of the node. Of course, you must reference it through this.$refs.menu-wrapper

    reply
    0
  • Cancelreply