- 前端(Web App) - JavaScript(React)wandarealmwuhan.cn
使用React和JavaScript来创建一个简单的Web App界面:
jsx
import React from ‘react’;
import ReactDOM from ‘react-dom’;
function App() {
return (
Hello, World! This is a simple React App.
);
}
ReactDOM.render(, document.getElementById(‘root’));
2. 后端(Node.js)
使用Node.js和Express来创建一个简单的RESTful API:
javascript
const express = require(‘express’);
const app = express();
const port = 3000;
app.get(‘/’, (req, res) => {
res.send(‘Hello, World! This is a simple Node.js server.’);
});
app.listen(port, () => {
console.log(Server is running on port ${port}.
);
});
3. 移动App(Android) - Java(使用Android Studio)
Android Studio中的Activity示例:
java
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView textView = findViewById(R.id.textView);
textView.setText("Hello, World! This is a simple Android App.");
}
}
4. 移动App(iOS) - Swift(使用Xcode)
Xcode中的ViewController示例:
swift
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let label = UILabel()
label.text = "Hello, World! This is a simple iOS App."
label.frame = CGRect(x: 50, y: 150, width: 200, height: 20)
self.view.addSubview(label)
}
}
请注意,这些只是非常基础的示例,用于展示如何使用这些语言开始一个App项目。一个完整的App项目将涉及更多的代码、设计、测试和部署步骤。