dcloudio / dcloudio/uni-app

prop传递是对象,对象内部value值为function的key直接被删除

Open
#1,864 0 comments 0 reactions 0 assignees View on GitHub
不明确复现步骤、未提供复现工程
Dominant language
JavaScript
Stars
41.6k
Forks
3.7k
Avg merge
7h 6m
Merged PRs (30d)
6

Description

**问题描述**
父组件向组组件传递对象时,如果对象内部value值为function的key直接会被删除,如果直接传递function则正常

**复现步骤**
**father.vue**
```



import child from './child.vue'
export default {
components: {
child
},
data() {
return {
fatherData: {
a: 1,
b: {
isShow: function() {
console.log("data定义对象属性函数");
}
}
},
fatherFcuntion: function() {
console.log("data定义函数变量");
},
}
},
methods: {
fatherMethod() {
console.log("method的定义函数");
},
}
}

```
**child.vue**
```


child

export default({
name: "child",
props: {
fatherData: {
type: Object,
default: function() {
return {};
}
},
fatherFunction: {
type: Function,
default: function() {
return function() {}
}
},
fatherMethod: {
type: Function,
default: function() {
return function() {}
}
}
},
mounted() {
console.log("父组件data定义的变量包含函数", this.fatherData);
console.log("父组件data定义的函数变量", this.fatherFunction);
console.log("父组件method定义的函数", this.fatherMethod);
}
})

```

**预期结果**
下图为vue中测试的结果
![image](https://user-images.githubusercontent.com/40915232/86429456-283f5b80-bd22-11ea-9cd9-2e15dbe8c68f.png)
child.vue中展示的this.fatherData可以看到isShow的属性

**实际结果**
下图为uniapp中测试结果
![image](https://user-images.githubusercontent.com/40915232/86429510-65a3e900-bd22-11ea-934c-7b6450314f00.png)
child.vue中展示的this.fatherData的isShow属性被删除

**系统信息:**
- 发行平台: 微信小程序
- 操作系统 微信开发者工具1.03.2006090
- HBuilderX版本 2.7.9
- uni-app版本 2.0.0-27920200527001
- 设备信息 iPhone8 XR

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.