[英]Getting custom component prop value in Vue app
I have a custom checkmark I created.我创建了一个自定义复选标记。
Vue.component('checkle', {
props: ['crisis'],
template: '<input type="checkbox" class="form-check-input" />',
mounted: function() {
var vm = this
$(this.$el).on('change', function() {
vm.$emit('change')
})
}
})
<checkle crisis="crisisvalue"
v-model="Model"
@change="changeLEC()" :disabled="!SomeValue">
</checkle>
As you can see I have a @change
which is defined in my Vue App.如您所见,我有一个在我的 Vue 应用程序中定义的@change
。 But I don't know how to access my crisis
prop inside my app.但我不知道如何在我的应用程序中访问我的crisis
道具。 Is there anyway to do this?有没有办法做到这一点?
https://v2.vuejs.org/v2/guide/events.html https://v2.vuejs.org/v2/guide/events.html
You can access props directly by name:您可以通过名称直接访问道具:
@change="changeLEC(crisis)"
or this.crisis
inside changeLEC
, which should be provided to your component as part of the methods:
property of your component object.或this.crisis
中的changeLEC
,它应该作为methods:
您的组件 object 的属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.