【问题标题】:Use Underscore.js in a Titanium Alloy project在钛合金项目中使用 Underscore.js
【发布时间】:2017-08-02 17:07:09
【问题描述】:

如何在钛合金项目中使用内置的下划线库。

docs 中说要执行以下操作:

var _ = require("alloy/underscore")._;

但是,每当我这样做时,我都会收到以下错误:

17:22:55 [ERROR] [iphone, 10.3.3, 192.168.0.64] {
"message": "undefined is not an object (evaluating '_.extend')", 
"line": 1179, 
"column": 6, 
"stack": "Controller
createController
onClickDetails
"}

所以我的问题是,如何使用 Alloy 中内置的 Underscore.js 库

【问题讨论】:

    标签: titanium appcelerator appcelerator-titanium titanium-alloy appcelerator-alloy


    【解决方案1】:

    原来下划线已经被导入了,所以你可以直接使用它而无需实际执行 require 语句。例如

    Ti.API.info(_.VERSION);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-18
      • 1970-01-01
      相关资源
      最近更新 更多