前端插件式辅助包 bitorjs

  • 有时我们期望在前端开发时可以有以下功能集成
  1. 让项目迅速集成开发插件的功能
  2. 使用注解式路由
  3. 使用中间件
  4. 让你开发nodejs 项目与 前端项目习惯统一
  5. 数据模拟与真实请求快速无缝切换

so, let`s 安装吧:

npm install -S bitorjs
  • 下面, 我们使用 bitorjs 开一个 vue 项目
  1. 使用 vue 官方脚手架 vue-cli 创建 项目
 $ vue init webpack xxx
  1. 安装依赖
 $ npm install -S bitorjs
 $ npm install -S vuex vuex-persist
 $ npm install -D babel-plugin-transform-decorators-legacy
 
 // and add the following line to your .babelrc file:
 
 {
 		"plugins": ["transform-decorators-legacy"]
 }
  1. 创建 config/index.env.js

  2. 修改 src/main.js

 // The Vue build version to load with the `import` command
 // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
 import Vue from 'vue'
 import Application from 'bitorjs';
 import App from './App'

 Vue.config.productionTip = false

 new Application({}, App, "#app").start(app => {
   app.watch(require.context('../config', false, /.js$/))
   app.watch(require.context('.', true, /^((?!/view/).)+.(vue|js)$/));
 })

修改 router/index.js

 import {
 Get,
 Controller
 } from 'bitorjs'
 import HelloWorld from '@/components/HelloWorld'
 
 @Controller('/')
 export default class {
   @Get('/')
   async index(ctx){
   		ctx.render(HelloWorld)
   }
 }

到此, 我们已开启了 bitorjs 之旅

上 一 篇: 前端库新作 Bitorjs 开源啦

文档地址: https://bitorjs.github.io/

开源地址: https://github.com/bitorjs/bitorjs

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值