Update App Development Guide
parent
4e046a58a4
commit
412d641be3
@ -8,7 +8,7 @@ Of course we must start with a classic.
|
||||
|
||||
### app.js
|
||||
|
||||
```
|
||||
```js
|
||||
app.setDocument('<h1 style="color: #fff">Hello, world!</h1>');
|
||||
```
|
||||
|
||||
@ -35,7 +35,7 @@ Let's take advantage of code running on the server and create a little hit count
|
||||
|
||||
### app.js
|
||||
|
||||
```
|
||||
```js
|
||||
async function main() {
|
||||
let db = await shared_database('visitors');
|
||||
let count = parseInt((await db.get('visitors')) ?? '0') + 1;
|
||||
@ -66,7 +66,7 @@ Suppose you don't want to create your entire app in a single server-side file as
|
||||
|
||||
### app.js
|
||||
|
||||
```
|
||||
```js
|
||||
async function main() {
|
||||
let html = utf8Decode(await getFile('index.html'));
|
||||
app.setDocument(html);
|
||||
@ -77,7 +77,7 @@ main();
|
||||
|
||||
### index.html
|
||||
|
||||
```
|
||||
```html
|
||||
<html>
|
||||
<head>
|
||||
<script type="module" src="script.js"></script>
|
||||
@ -90,7 +90,7 @@ main();
|
||||
|
||||
### script.js
|
||||
|
||||
```
|
||||
```js
|
||||
window.addEventListener('load', function() {
|
||||
document.body.appendChild(document.createTextNode('Hello, world');
|
||||
});
|
||||
@ -110,7 +110,7 @@ While making calls between the client and the server, it is possible to pass fun
|
||||
|
||||
### app.js
|
||||
|
||||
```
|
||||
```js
|
||||
import * as tf from '/tfrpc.js';
|
||||
|
||||
function sum() {
|
||||
@ -130,7 +130,7 @@ main();
|
||||
|
||||
### index.html
|
||||
|
||||
```
|
||||
```html
|
||||
<html>
|
||||
<body>
|
||||
<h1 id='result'>Calculating...</h1>
|
||||
@ -141,7 +141,7 @@ main();
|
||||
|
||||
### script.js
|
||||
|
||||
```
|
||||
```js
|
||||
import * as tf from '/static/tfrpc.js';
|
||||
|
||||
window.addEventListener('load', async function() {
|
||||
|
Loading…
Reference in New Issue
Block a user