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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM