vuejs中用组件的props怎么传个function过去呢?
<show-modal :show.sync="showModal" fns='function(){alert(123)}'>
<!--
you can use custom content here to overwrite
default content
-->
<h3 slot="header">custom header</h3>
<div slot='footer'>
<button @click='oKfns' class="modal-default-button">
OK
</button>
<button @click='showModal = false' class="modal-default-button">
CANCEL
</button>
</div>
</show-modal>
我的想法是fns传过去一个方法,然后组件内部使用这个方法
<template lang="html">
<div class="modal-mask" v-show="show" transition="modal">
<div class="modal-wrapper">
<div class="modal-container">
<div class="modal-header">
<slot name="header">
default header
</slot>
</div>
<div class="modal-body">
<slot name="body">
default body
</slot>
</div>
<div class="modal-footer">
<slot name="footer">
default footer
<button class="modal-default-button"
@click="show = false">
OK
</button>
<button class="modal-default-button"
@click="fns">
cancel
</button>
</slot>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
data () {
return {}
},
props: {
show: {
type: Boolean,
required: true,
twoWay: true
},
fns : {
type : Function
}
}
}
</script>
现在是会报这个错~
vuejs新手求大神解答,轻喷!