我有一个表单,这是使用自定义组件,可供我们使用。注意:我没有访问自定义组件的权限,添加@input解决方案对我不起作用。有没有什么方法可以从我的自定义组件中获得值,而不需要在组件中进行更改?
<section class="container__content">
<div>Details</div>
<div class="personal-info">
<textfield type="text" label="Name" placeholder="Shweta"></textfield>
<textfield type="text" label="ID" placeholder="sm1234"></textfield>
</div>
发布于 2020-06-09 04:05:50
如果我理解正确的话,您需要$refs对象。https://vuejs.org/v2/guide/components-edge-cases.html#Accessing-Child-Component-Instances-amp-Child-Elements basic代码示例:
<template>
<child ref="childA"></child>
<child ref="otherCHild></child>
</template>
this.$refs.childA.something
this.$refs.otherCHild.something这两个$refs变量将是包含在它们各自的子级中的something变量中的值。
我在utils库中使用它来监视我想要在父级中触发操作的更改(比如监视上载完成或错误)。
https://stackoverflow.com/questions/62218225
复制相似问题