首页 文章

如何将lodash导入NativeScript Playground

提问于
浏览
1

我正在学习NativeScript并尝试在他们的Playground中使用一些教程,他们正在使用lodash . 根据NativeScripts的博客,你应该可以使用下拉列表在操场上要求lodash模块 . (https://www.nativescript.org/blog/nativescript-playground-is-on-fire

enter image description here

enter image description here

这工作,并在应用程序文件夹中添加lodash文件夹 . 当我尝试导入它时会发生此问题 . 它说没有找到lodash . 我试过了:

import * as _ from 'lodash';
import _ from 'lodash';
var _ = require ('lodash');

还有许多其他建议,但这些建议似乎都没有效果 . 我尝试添加@types(NativeScript表示它们会自动添加),但即使添加了@ types / lodash也失败了 .

enter image description here

有人知道如何在NativeScript游乐场中完成这项工作吗?谢谢 .

1 回答

  • 1

    尝试使用相对路径的简单require语句 .

    const _ = require('../lodash');
    

相关问题