<template>
<div></div>
</template>
<script>
export default {
name: "page",
props: {},
data() {
return {
arr11: [
{ name: "1322", age: "112" },
{ name: "2322", age: "212" },
{ name: "3322", age: "312" },
],
arr21: { name: "1322", age: "112" },
arr31: "22",
};
},
mounted() {
console.log(this.objOrArrFun(this.arr11));
console.log(this.objOrArrFun(this.arr31));
console.log(this.objOrArrFun(this.arr21));
},
destroyed() {},
methods: {
//判断数组或者对象, //typeof 不能判断数组和对象
objOrArrFun(arr) {
if (arr instanceof Array) return "数组0";
if (typeof arr === "object") return "对象0";
return "不是数组对象0";
},
},
};
</script>
<style lang="scss" scoped>
h4 {
width: 800px;
line-height: 24px;
margin-left: 40px;
}
</style>
06-27
438
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
01-14
7703
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-31
822
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-25
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)