Update App Development Guide
parent
4e046a58a4
commit
412d641be3
@ -8,7 +8,7 @@ Of course we must start with a classic.
|
|||||||
|
|
||||||
### app.js
|
### app.js
|
||||||
|
|
||||||
```
|
```js
|
||||||
app.setDocument('<h1 style="color: #fff">Hello, world!</h1>');
|
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
|
### app.js
|
||||||
|
|
||||||
```
|
```js
|
||||||
async function main() {
|
async function main() {
|
||||||
let db = await shared_database('visitors');
|
let db = await shared_database('visitors');
|
||||||
let count = parseInt((await db.get('visitors')) ?? '0') + 1;
|
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
|
### app.js
|
||||||
|
|
||||||
```
|
```js
|
||||||
async function main() {
|
async function main() {
|
||||||
let html = utf8Decode(await getFile('index.html'));
|
let html = utf8Decode(await getFile('index.html'));
|
||||||
app.setDocument(html);
|
app.setDocument(html);
|
||||||
@ -77,7 +77,7 @@ main();
|
|||||||
|
|
||||||
### index.html
|
### index.html
|
||||||
|
|
||||||
```
|
```html
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<script type="module" src="script.js"></script>
|
<script type="module" src="script.js"></script>
|
||||||
@ -90,7 +90,7 @@ main();
|
|||||||
|
|
||||||
### script.js
|
### script.js
|
||||||
|
|
||||||
```
|
```js
|
||||||
window.addEventListener('load', function() {
|
window.addEventListener('load', function() {
|
||||||
document.body.appendChild(document.createTextNode('Hello, world');
|
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
|
### app.js
|
||||||
|
|
||||||
```
|
```js
|
||||||
import * as tf from '/tfrpc.js';
|
import * as tf from '/tfrpc.js';
|
||||||
|
|
||||||
function sum() {
|
function sum() {
|
||||||
@ -130,7 +130,7 @@ main();
|
|||||||
|
|
||||||
### index.html
|
### index.html
|
||||||
|
|
||||||
```
|
```html
|
||||||
<html>
|
<html>
|
||||||
<body>
|
<body>
|
||||||
<h1 id='result'>Calculating...</h1>
|
<h1 id='result'>Calculating...</h1>
|
||||||
@ -141,7 +141,7 @@ main();
|
|||||||
|
|
||||||
### script.js
|
### script.js
|
||||||
|
|
||||||
```
|
```js
|
||||||
import * as tf from '/static/tfrpc.js';
|
import * as tf from '/static/tfrpc.js';
|
||||||
|
|
||||||
window.addEventListener('load', async function() {
|
window.addEventListener('load', async function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user