Comments (3)
奇怪的是这个问题在桌面上不是必现的。在手机上能必现。
from eruda.
getter 是设置在 cc.Node 的 prototype 上面,但这里判断用的 obj 是 cc.Node 的父类的 prototype
// getter设置在A的prototype上,B是A的父类
var B = function () {};
var A = function () { this._data = 'eruda' };
A.prototype = Object.create(B.prototype);
Object.defineProperty(A.prototype, 'data', {
get: function () { return this._data }
});
var a = new A();
console.log(a);
不知我理解是否有误,上面代码在Chrome和safari ios试了结果并没有问题。能否给下在手机上出错的最小错误示例代码?
from eruda.
你的理解是正确的,我找到重现代码了,看来不是 eruda 的问题。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script type='text/javascript' src='./eruda.min.js'></script>
<script type='text/javascript'>
eruda.init();
function Base () {}
Object.defineProperty(Base.prototype, 'data', {
get: undefined,
});
function Sub () {}
Sub.prototype = Object.create(Base.prototype);
Object.defineProperty(Sub.prototype, 'data', {
get: function () {
console.error('use prop over data');
}
});
console.log(new Sub());
</script>
</body>
</html>
运行以上网页,就会出现 use prop over data
的报错。
在这里 defineProperty 时,get 传入的是 undefined。虽然发生了继承,子类的 get 仍然无法覆盖基类的 undefined,property descriptor 永远只能拿到 { enumerable:false, get: undefined },不论基类是否启用 configurable 都会这样。
当然,这里基类的 get 一开始就不应该定义成 undefined。这是我们内部的错误。
from eruda.
Related Issues (20)
- element.style{ } Doesn't responses when I touch on it.(I am unable use it..)
- element.style{ } Doesn't responses when I touch on it.(I am unable use it..)
- Script issues with GitHub, GitLab, etc HOT 2
- Vue 等环境下对 Obect 设置了 set 和 get 都会被输出,这个有办法屏蔽只保留具体的 key,不展示 get set
- How do i "inject" code onto a website using this?
- Can't copy long strings of text
- Icon does not appear on discord HOT 2
- gj
- indexeddb support
- [Feature request] Application page
- Road69_Silence
- Eruda
- Eruda
- Good
- Counsel does not show accurate logs HOT 1
- Custom theme
- Make backers.svg lazy-loading
- Is there a function to make Eruda immediately show up? HOT 2
- Can't execute js and open eruda on opera gx mobile
- 功能请求:改进对 Set 的支持
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eruda.