fix: 🐛 修复 Tabbar 错误地抛出提示信息的问题

This commit is contained in:
xuqingkai 2024-01-10 17:39:34 +08:00
parent 7cdda00f49
commit 1c89ed0a71

View File

@ -24,7 +24,7 @@ export default {
}
</script>
<script lang="ts" setup>
import { type CSSProperties, computed, onMounted } from 'vue'
import { type CSSProperties, computed } from 'vue'
import { isDef, objToStyle } from '../common/util'
import { useParent } from '../composables/useParent'
import { TABBAR_KEY } from '../wd-tabbar/types'
@ -99,32 +99,6 @@ const active = computed(() => {
}
})
onMounted(() => {
init()
})
/**
* 初始化将组件信息注入父组件
*/
function init() {
if (tabbar && tabbar.children && isDef(props.name)) {
const repeat = checkRepeat(tabbar.children, props.name, 'name')
if (repeat > -1) {
console.error('[wot-design] warning(wd-tabbar-item): name attribute cannot be defined repeatedly')
}
}
}
/**
* 检查是否存在重复name属性
* @param {Array} currentList
* @param {String} checkValue 比较的重复值
* @param {String} key 键名
*/
function checkRepeat(currentList: any[], checkValue: string | number, key: string): number {
return currentList.findIndex((item) => item[key] === checkValue)
}
/**
* 点击tabbar选项
*/