Skip to content

请问在vue3项目中使用kbone-ui的mp-navigation-bar组件时,如何绑定bindback事件? #476

@zhuxl1997

Description

@zhuxl1997

如题,请问在vue3项目中使用kbone-ui的mp-navigation-bar组件时,如何绑定bindback事件?

已经尝试使用kbone-event-map,但是没有效果,代码如下:

<template>
    <mp-navigation-bar :loading.attr="mpNavigationBar.loading" :show.attr="mpNavigationBar.show.toString()"
                       :animated.attr="mpNavigationBar.animated.toString()" :color.attr="mpNavigationBar.color"
                       :background.attr="mpNavigationBar.background" :back.attr="true" :kbone-event-map="{bindback: () => goBack()}">
        <span slot="center">微信原生</span>
    </mp-navigation-bar>


</template>
<script>
import {computed, onMounted, reactive, ref, watch} from "vue";
import {useRouter} from "vue-router";
import {useStore} from "vuex";

export default {
    setup() {

        const mpNavigationBar = reactive({
            loading: false,
            color: '#fff',
            background: '#1989fa',
            show: true,
            animated: false
        })
        
        const goBack = (e) => {
            console.log(123, e)
        }

        window.addEventListener('back', (e) => {
            console.log(123, e)
        })


        return {
            mpNavigationBar,
            goBack
        }
    }
}


</script>

<style lang='less'>
@primary: var(--statusbar-height);
.kbone-content {
  width: 100%;
  height: calc(~"100% - 46px - @{primary}");
  overflow-y: scroll;
  text-align: left;
}


</style>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions