diff --git a/src/nav-bar/index.js b/src/nav-bar/index.js
index 76b73d12f..4ce995fb1 100644
--- a/src/nav-bar/index.js
+++ b/src/nav-bar/index.js
@@ -1,3 +1,5 @@
+import { ref, onMounted } from 'vue';
+
// Utils
import { createNamespace } from '../utils';
import { BORDER_BOTTOM } from '../utils/constant';
@@ -24,82 +26,79 @@ export default createComponent({
emits: ['click-left', 'click-right'],
- data() {
- return {
- height: null,
+ setup(props, { emit, slots }) {
+ const navBar = ref(null);
+ const height = ref(null);
+
+ onMounted(() => {
+ if (props.placeholder && props.fixed) {
+ height.value = navBar.value.getBoundingClientRect().height;
+ }
+ });
+
+ const onClickLeft = (event) => {
+ emit('click-left', event);
};
- },
- mounted() {
- if (this.placeholder && this.fixed) {
- this.height = this.$refs.navBar.getBoundingClientRect().height;
- }
- },
+ const onClickRight = (event) => {
+ emit('click-right', event);
+ };
- methods: {
- genLeft() {
- const leftSlot = this.$slots.left?.();
-
- if (leftSlot) {
- return leftSlot;
+ const renderLeft = () => {
+ if (slots.left) {
+ return slots.left();
}
return [
- this.leftArrow &&