• TS


    //html文件
    <!DOCTYPE html>
    <html lang="en">
        <head>
            <meta charset="utf-8" />
            <title>TypeScript HTML App_for_test</title>
        </head>
        <body>
            <h1>TypeScript HTML App_for_test</h1>
        </body>
        <script src="app.js"></script>
    </html>
    
    //app.js内容
    class Greeter {
        constructor(public greeting: string) {
        }
    greet() {
        return "<h1>" + this.greeting + "</h1>";
        }
    };
    
    var greeter = new Greeter("hello,world");
    var str = greeter.greet();
    document.body.innerHTML = str;
    
    /***************************************************************/
    
    class RayTracer {
        private maxDepth = 5;
        private intersections() {
    
        }
    
    private testRay() {
    
        }
    
    render() {
        }
    };
    function defaultScene(): Scene {
        return {
        }
    }
    function exec() {
        var canv = document.createElement("canvas");
        canv.width = 256;
        canv.height = 256;
        document.body.appendChild(canv);
        var ctx = canv.getContext("2d");
        var rayTracer = new RayTracer();
        return rayTracer.render( defaultScene() );
        }
    exec()
    

      //第一次使用typescript,为毛感觉和js差那么多啊,太不习惯了

    interface

    interface Person {
        firstname: string;
        lastname: string;
    }
    
    function greeter(person : Person) {
        return "Hello, " + person.firstname + " " + person.lastname;
    }
    
    var user = {firstname: "Jane", lastname: "User"};
    
    document.body.innerHTML = greeter(user);
    

      

  • 相关阅读:
    匈牙利游戏
    钓鱼
    路由选择
    借教室
    有趣的数
    广告印刷
    海战
    暑假周进度报告(一)
    在Oracle创建一个自己用的用户及角色
    下载,安装oracle数据库以及navicat连接数据库
  • 原文地址:https://www.cnblogs.com/diligenceday/p/3558986.html
Copyright © 2020-2023  润新知