vue 子组件调用父组件方法

//父组件

<btnCommit @btnsubmit="submit"></btnCommit>

//子组件

 

<template>
<view class="">
<view class="btn_commit">
<button type="primary" @click="submit">提交</button>
</view>
</view>
</template>

<script>
export default{
data(){
return{

}
},methods:{
submit(){
this.$emit("btnsubmit",1);
}
}
}
</script>

<style>
.btn_commit{
height: 70px;
line-height: 70px;
width: 100%;
background-color: #FFF;
position: fixed;
bottom: 0;

}
.btn_commit button{
width: 80%;
margin-top: 10px;
}
</style>

 

//注册公共组件
import btnCommit from 'common/btn-commit.vue'
Vue.component('btnCommit',btnCommit)

 

//ok

 

posted @ 2020-08-12 16:05  appdesign  阅读(694)  评论(0)    收藏  举报