【发布时间】:2017-10-10 22:32:53
【问题描述】:
我在尝试使用 Angular FullStack 生成器导入 UIkit 时遇到此错误:
Module 'uikit' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
这就是我所做的:
webpack.make.js
if(TEST) {
config.entry = {};
} else {
config.entry = {
app: './client/app/app.js',
polyfills: './client/polyfills.js',
vendor: [
'angular',
'angular-animate',
'angular-aria',
'angular-cookies',
'angular-resource',
'angular-sanitize',
'angular-ui-router',
'lodash',
'uikit'
]
};
}
app.js
...
import uikit from 'uikit';
...
angular.module('myApp', [ngCookies, ngResource, ngSanitize, uiRouter, uikit])
但是,我可以通过将以下内容添加到我的 app.scss 来使用样式指令:
@import'~uikit/dist/css/uikit.css';
但是,如果我不导入 JS 模块,我会得到UIkit is not defined。
如何将 UIkit 正确导入我的项目??
提前致谢:)
【问题讨论】:
-
你试过
import UIkit from 'uikit';吗?当然 css 可以工作,但不确定 js 插件。它适用于 Vue 和 React,但不是关于 Angular 文档的世界。 -
@cssBlaster21895,如果我按照你说的导入它,我会收到这个新错误:
Failed to instantiate module function plugin(UIkit) due to: [$injector:strictdi] plugin is not using explicit annotation and cannot be invoked in strict mode并且页面变为空白... -
所以 UIkit 似乎对角度不友好。它的代码缺少注释。也许您可以尝试使用npmjs.com/package/ng-annotate-webpack-plugin 或github.com/huston007/ng-annotate-loader。但我认为这可能很难。 Javascript宁可不行,终于可以导入css/scss了。
标签: javascript angular-fullstack getuikit