sard-uniapp
Version:
sard-uniapp 是一套基于 Uniapp + Vue3 框架开发的兼容多端的 UI 组件库
16 lines (15 loc) • 430 B
JavaScript
import { computed, reactive, unref } from 'vue';
import { uniqid } from '../utils';
export function useKeyList(list) {
const keyMap = new WeakMap();
return computed(() => {
return unref(list).map((item) => {
const key = keyMap.get(item) || uniqid();
keyMap.set(item, key);
return reactive({
data: item,
key,
});
});
});
}