提交 4ea5e30a 编写于 作者: S suzigang

fix(address): add data error check

上级 3ad0e296
......@@ -256,6 +256,13 @@ export default create({
if (!data.length) return [];
data.forEach((item: RegionData) => {
if (!item.title) {
console.error('[NutUI] <Address> 请检查数组选项的 title 值是否有设置 ,title 为必填项 .');
return;
}
});
const newData: CustomRegionData[] = [];
data = data.sort((a: RegionData, b: RegionData) => {
......
......@@ -237,10 +237,18 @@ export default create({
const isCustom2 = computed(() => props.type === 'custom2');
const transformData = (data: RegionData[]) => {
console.log(data);
if (!Array.isArray(data)) throw new TypeError('params muse be array.');
if (!data.length) return [];
data.forEach((item: RegionData) => {
if (!item.title) {
console.error('[NutUI] <Address> 请检查数组选项的 title 值是否有设置 ,title 为必填项 .');
return;
}
});
const newData: CustomRegionData[] = [];
data = data.sort((a: RegionData, b: RegionData) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册