Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zhuxl1997 opened this issue Dec 28, 2023 · 3 comments

Comments

@zhuxl1997
Copy link

如题,请问在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>
@JimmyVV
Copy link
Contributor

JimmyVV commented Dec 28, 2023 via email

@JuneAndGreen
Copy link
Collaborator

直接监听 back 事件试试,去掉 bind,bind 本身就是绑定的意思。

@JimmyVV
Copy link
Contributor

JimmyVV commented Jan 11, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants