Jquery 在组件中与组件交互
我有一个按钮组件,我在自己的组件中使用它。到目前为止效果很好 此按钮的布尔属性为“加载”,用于确定是否显示微调器。我现在的问题是,如何从我的方法链接到这个按钮组件,并将加载属性更改为trueJquery 在组件中与组件交互,jquery,vue.js,Jquery,Vue.js,我有一个按钮组件,我在自己的组件中使用它。到目前为止效果很好 此按钮的布尔属性为“加载”,用于确定是否显示微调器。我现在的问题是,如何从我的方法链接到这个按钮组件,并将加载属性更改为true <template> <div> <button-component></button-component> </div> </template> <script> import ButtonCompo
<template>
<div>
<button-component></button-component>
</div>
</template>
<script>
import ButtonComponent from 'ButtonComponent';
export default {
components: {
ButtonComponent
},
methods: {
buttonClick() {
// Set loading to true
}
}
</script>
从“ButtonComponent”导入ButtonComponent;
导出默认值{
组成部分:{
按钮组件
},
方法:{
按钮点击{
//将加载设置为true
}
}
有两种方法可以做到这一点,我认为最简单的方法是使用v-ref
:
或者,您可以将加载属性添加到父级并同步它:
有几种方法可以做到这一点,我认为最简单的方法是使用
v-ref
:
或者,您可以将加载属性添加到父级并同步它:
谢谢。v-ref是我一直在寻找的解决方案!谢谢。v-ref是我一直在寻找的解决方案!
methods: {
buttonClick() {
this.$refs.loadingButton.loading = true;
}
}
data:{
loading: false,
},
methods: {
buttonClick() {
this.loading = true;
}
}