Node.js history

1. 2009 Node js was created by Ryan Dahl and other developers working at Joyent in 2009.

2. 2011 Node Package Manager was relasing as a open-source library 

3. 2014 io.js creaated a fork of the Node.js project

4. 2015 io.js and node.js work under new Node.js foundation, which including IBM, Microsoft, Paypal, Groupon

3. 9月 14, 2015. Node.js 4.0 released 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是一个简单的包括前后端的项目示例: ## 后端 ### 1. 创建项目 首先,在命令行中创建一个新的 Node.js 项目: ```bash mkdir backend cd backend npm init ``` ### 2. 安装依赖 安装 Express 和 body-parser: ```bash npm install express body-parser --save ``` ### 3. 创建路由 在 `backend` 目录下创建 `routes.js` 文件,添加以下代码: ```javascript const express = require('express'); const router = express.Router(); router.get('/api', (req, res) => { res.send('API is working!'); }); module.exports = router; ``` ### 4. 创建服务器 在 `backend` 目录下创建 `server.js` 文件,添加以下代码: ```javascript const express = require('express'); const bodyParser = require('body-parser'); const routes = require('./routes'); const app = express(); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); app.use('/', routes); const port = process.env.PORT || 3000; app.listen(port, () => console.log(`Server started on port ${port}`)); ``` ### 5. 运行项目 在命令行中运行以下命令启动服务器: ```bash node server.js ``` 现在,访问 `http://localhost:3000/api` 将会返回 `API is working!`。 ## 前端 ### 1. 创建项目 使用 Vue CLI 创建一个新的前端项目: ```bash vue create frontend ``` ### 2. 安装依赖 安装 axios: ```bash npm install axios --save ``` ### 3. 创建组件 在 `src/components` 目录下创建一个名为 `HelloWorld.vue` 的组件,添加以下代码: ```html <template> <div> <h1>{{ message }}</h1> </div> </template> <script> import axios from 'axios'; export default { data() { return { message: '' }; }, mounted() { axios .get('http://localhost:3000/api') .then(response => { this.message = response.data; }) .catch(error => { console.log(error); }); } }; </script> ``` ### 4. 创建页面 在 `src/views` 目录下创建一个名为 `Home.vue` 的页面,添加以下代码: ```html <template> <div> <HelloWorld /> </div> </template> <script> import HelloWorld from '@/components/HelloWorld.vue'; export default { name: 'Home', components: { HelloWorld } }; </script> ``` ### 5. 更新路由 在 `src/router/index.js` 中更新路由,将默认的路由指向 `Home` 页面: ```javascript import Vue from 'vue'; import VueRouter from 'vue-router'; import Home from '../views/Home.vue'; Vue.use(VueRouter); const routes = [ { path: '/', name: 'Home', component: Home } ]; const router = new VueRouter({ mode: 'history', base: process.env.BASE_URL, routes }); export default router; ``` ### 6. 运行项目 在命令行中运行以下命令启动前端开发服务器: ```bash npm run serve ``` 现在,访问 `http://localhost:8080` 将会显示 `API is working!`。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值