• nodejs文件调用-


    类的调用:

    Mail.js

    function Mail(user_name,password){
        this.user_name = user_name;
        this.password = password;
    }
    Mail.prototype.autoRun = function() {
        console.log(this.user_name+this.password);
    };
    module.exports = Mail;

    main.js

    const Mail = require('./Mail');
    let mail = new Mail("123","abc");
    mail.autoRun();

    函数的调用:

    Mail.js

    var m= require('./formula');
    var f = require('./function');

    m.add(1,2);
    f();

    formula.js

          function reduce(a,b){
              console.log(a-b);
          },
          function add(a,b){
              console.log(a+b);
          }
          module.exports = {
           reduce,
           add
          }

    function.js

    module.exports = function  print(){
         console.log("我是fun3的方法");
    }

  • 相关阅读:
    什么是操作系统
    去除按钮点击的边框
    unsupported time zone specified undefined
    w3c JS测试
    视频播放器
    document.write
    HTML4到HTML5
    MPU6050
    NRF24L01模块配置
    4-Four-Seeing hands
  • 原文地址:https://www.cnblogs.com/dongfangchun/p/12672031.html
Copyright © 2020-2023  润新知