gpt4 book ai didi

node.js - 使用nodejs从另一个CoffeeScript文件中获取CoffeeScript文件

转载 作者:搜寻专家 更新时间:2023-11-01 00:12:08 24 4
gpt4 key购买 nike

我想知道您是否能够从另一个 coffeescript 中获取一个 coffeescript。

我的示例代码来自文件“user.coffee”

class UserObj
constructor: (@name) ->
console.log @name

主文件中的示例代码

require "./user.coffee"

User = new UserObj "Example"

这可能来自 coffeescript 文件还是仅来自 js 文件?

最佳答案

是的,这是可能的。

用户.咖啡:

exports.UserObj = 
class UserObj
constructor: (@name) ->
console.log @name

主要咖啡:

{UserObj} = require "./user"

User = new UserObj "Example"

关于node.js - 使用nodejs从另一个CoffeeScript文件中获取CoffeeScript文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9939672/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com