只是让我困惑 Firebug 控制台上显示的错误:
Uncaught TypeError: Object #<Object> has no method 'Sin'
Uncaught TypeError: Object #<Object> has no method 'Cos'
但我的代码给出了 Math.PI 的值
我完全困惑了,我不知道我做错了什么,非常感谢任何帮助。
我的代码:
function callCordinates(angle){
console.log(Math.PI); // shows 3.14...
console.log(Math.Cos(0)); // throws error. :(
var x1 = 480 + 100 * Math.Cos(angle * (Math.PI / 180));
var y1 = 155 + 100 * Math.Sin(angle * (Math.PI / 180));
}
最佳答案
其Math.sin ,所以改变
Math.Sin(angle * (Math.PI / 180));
至
Math.sin(angle * (Math.PI / 180));
及其 Math.cos ,所以改变:
Math.Cos
至
Math.cos
关于javascript - 未捕获的类型错误 : Object #<Object> has no method 'Sin' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19513507/