zoukankan      html  css  js  c++  java
  • 关于Fekit的安装与测试

    一. Fekit的安装

      1.cmd输入指令

    $ npm install fekit -g

      2.初始化方法

    $ fekit init

      3.创建本地服务

    $ fekit server

      4.创建同时改端口(8080)

    $ fekit server -p 8080

      5.查看其它参数

    $ fekit server --help

    二. 模型的共享

      1.模型定义

       //模型定义    model.js 
       var name = "LiuYashion";
     
       function printName(){
           console.log(name)
       };
     
       module.exports = {
           myFunction:printName()
       }

      2.模块加载

         //模块加载    index.js
         var temp = require(../model.js)    //此处填写相对链接
         
         temp.myFunction()

      3.模块引用

        //模块引用    index.html
        <script src="/prd/../index.js"><script>    //此处填写相对链接

      4.修改config文件

        {
            "compiler": "modular",
            "name": "LiuYashion",
            "version": "0.0.0",
            "dependencies": {},
            "alias": {},
            "export": [
                "scripts/index.js"  //填写入模块加载文件    
            ]
        }

      5.此时已经可以执行printName(),输出LiuYashion

        1.务必在模块应用中添加/prd/,修改为生产模式
        2.修改config文件,添加模块加载文件

    三. 数据的共享

      1.新建好JSON文件

        {
            "data":[
                {"myloaction":"ShenZhen"},
                {"myloaction":"ShenZhen"},
                {"myloaction":"ShenZhen"},
                {"myloaction":"ShenZhen"},
                {"myloaction":"ShenZhen"},
                {"myloaction":"ShenZhen"},
                {"myloaction":"ShenZhen"}
            ]
        }  //list.json

      2.设置好配置文件config

        module.exports =  {
            rules:[
                {
                    "pattern":/dataList/,
                    "respondwith":"list.json"  //这里是相对路径
                }
            ]
        }    

      3.在index.js中加入ajax

        $.ajax({
            type:"post",
            url:"dataList",    //    这个变量可通过localhost/dataList访问到
            data:"",
            success:function(res){
                console.log(res)
            }
        });    

      4.重新修改本地化服务

     $  fekit server -m "../../../mock.conf"

      

    四. 

      这是数据和方法被放入了同一端口,大功告成.具体项目后面在写...

  • 相关阅读:
    ASP.NET——基础 14、Server
    ASP.NET——基础 15、HttpHandler
    ASP.NET——基础 2、ViewState
    MYSQL VS2010 中文乱码问题
    ASP.NET——基础 10、Web开发的一些基本原则1
    数据结构与算法 2、单向/双向链表
    C#操作XML日志
    web开发入门级学习经验(菜鸟级)
    笔记:键盘键值一览表(JS)
    笔记:JS事件的捕获与冒泡
  • 原文地址:https://www.cnblogs.com/nemoro1928/p/5543791.html
Copyright © 2011-2022 走看看