Vue. How to get a value of a quot;keyquot; attribute in created element(Vue.如何获取“键的值?创建元素中的属性)
问题描述
我尝试创建一个组件并获取其在 axios 中使用的密钥.元素已创建,但我无法获得密钥.未定义
I try to create a components and get its key for using in axios. Elements created, but I can't get a key. It's undefined
我尝试了一些变体,但没有结果 - @key 为空.
I try some variants, but no result - @key was empty.
推荐答案
这个答案回答了如何将密钥传递给子组件的问题.如果您只想从子组件内部获取当前密钥,请使用投票最高的答案.<小时>key
是 Vue 中的 特殊属性.您必须将您的财产称为其他名称.
This answer answers the question of how you would pass the key to a child component. If you just want to get the current key from inside the child component, use the highest voted answer.
key
is a special attribute in Vue. You will have to call your property something else.
这里是使用 pkey
的替代方法.
Here is an alternative using pkey
instead.
这篇关于Vue.如何获取“键"的值?创建元素中的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!