国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.5KB

  1. <!doctype html>
  2. <title>CodeMirror: TypeScript mode</title>
  3. <meta charset="utf-8"/>
  4. <link rel=stylesheet href="../../doc/docs.css">
  5. <link rel="stylesheet" href="../../lib/codemirror.css">
  6. <script src="../../lib/codemirror.js"></script>
  7. <script src="javascript.js"></script>
  8. <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
  9. <div id=nav>
  10. <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
  11. <ul>
  12. <li><a href="../../index.html">Home</a>
  13. <li><a href="../../doc/manual.html">Manual</a>
  14. <li><a href="https://github.com/codemirror/codemirror">Code</a>
  15. </ul>
  16. <ul>
  17. <li><a href="../index.html">Language modes</a>
  18. <li><a class=active href="#">TypeScript</a>
  19. </ul>
  20. </div>
  21. <article>
  22. <h2>TypeScript mode</h2>
  23. <div><textarea id="code" name="code">
  24. class Greeter {
  25. greeting: string;
  26. constructor (message: string) {
  27. this.greeting = message;
  28. }
  29. greet() {
  30. return "Hello, " + this.greeting;
  31. }
  32. }
  33. var greeter = new Greeter("world");
  34. var button = document.createElement('button')
  35. button.innerText = "Say Hello"
  36. button.onclick = function() {
  37. alert(greeter.greet())
  38. }
  39. document.body.appendChild(button)
  40. </textarea></div>
  41. <script>
  42. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  43. lineNumbers: true,
  44. matchBrackets: true,
  45. mode: "text/typescript"
  46. });
  47. </script>
  48. <p>This is a specialization of the <a href="index.html">JavaScript mode</a>.</p>
  49. </article>