jspm找不到'功能'Aurelia应用程序的插件
jspm cannot find globalResources of a 'feature' plugin for Aurelia app
Aurelia文档描述了如何在http://aurelia.io/docs.html#features
我遇到了一些麻烦,因为jspm或Aurelia似乎正在转换资源路径。我发现,如果用.aurelia.use.feature('./plugins/auth');
指定当前路径,则在引导时无法找到calvert-auth/index.js
。请求看起来是正确的,但浏览器抛出404错误。我只是通过从.aurelia.use.feature('plugins/auth');
中删除"./"来解决这个问题
接下来,我在index.s的configure()中向frameworkConfig.globalResources('auth')添加了一个调用。这导致了一个新的404错误,因为请求的是calvert-auth/auth.html,而不是预期的calvert-auth/auth.js
我怀疑问题可能在jspm配置或corejs中,但还无法隔离它。
如何为Aurelia创建和使用内部功能插件?以下是类别:
config.js
...
paths: {
"*": "dist/*",
"github:*": "jspm_packages/github/*",
"npm:*": "jspm_packages/npm/*"
},
...
main.js
import 'bootstrap';
import authConfig from './auth-config';
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging()
.feature('plugins/calvert-auth', (baseConfig) => {
baseConfig.configure(authConfig);
});
aurelia.start().then(a => a.setRoot());
}
插件/calvert auth/auth.js
export class Auth {
constructor() {
console.log('Auth: constructor()');
}
}
插件/calvert auth/index.js
import {BaseConfig} from './baseConfig';
export function configure(frameworkConfig, configCallback) {
frameworkConfig.globalResources('./auth');
let baseConfig = frameworkConfig.container.get(BaseConfig);
if (configCallback !== undefined && typeof(configCallback) === 'function') {
configCallback(baseConfig);
}
}
试试这个:
假设你的代码在上面,并且这个结构:
main.js
plugins/calvert-auth/index.js
plugins/calvert-auth/auth.js
在main.js:中
import 'bootstrap';
import authConfig from './auth-config';
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging()
.feature('plugins/calvert-auth', (baseConfig) => {
baseConfig.configure(authConfig);
});
aurelia.start().then(a => a.setRoot());
}
在插件/calvert auth/index.js:中
export function configure(frameworkConfig, configCallback) {
// this assumes you're importing a view model
frameworkConfig.globalResources('auth');
}
在插件/calvert auth/auth.js:中
import {noView} from 'aurelia-framework';
@noView
export class Auth {
constructor() {
console.log('Auth: constructor()');
}
}
相关文章:
- firefox插件:退出不工作的应用程序观察器
- 在通知点击时使用Ion中的OneSignal插件路由到应用程序中的状态
- React/Node应用程序中的Facebook评论插件.js仅在刷新时显示
- 我想在混合移动应用程序中使用Sqlite插件(Cordova)创建一个示例项目
- 使用cordova插件删除iOS中应用程序的临时目录
- 应用程序版本插件问题
- Cordova应用程序在安卓系统上运行,但线程似乎在ios上冻结了;“由于页面加载而重置插件”;
- JQuery插件选择不在我的Ionic应用程序中工作
- 可以't从客户端应用程序引用插件中定义的静态方法
- 网站应用程序的文件上传插件和显示
- 在应用程序加载和 angularjs 中的每个状态更改时调用 jquery 插件
- 将代码片段插件添加到 Rails 应用程序中的 CKEditor
- iOS 中的 Ionic 应用程序无法使用 cordova 插件媒体播放本地音频
- 如何在不使用电子邮件作曲家插件的情况下从离子应用程序发送电子邮件
- 将js应用程序与webpack捆绑在一起,以获得wordpress插件
- 如何在 GWT 中向 Web 应用程序添加对插件的支持
- 如何在 angular js 应用程序中调用 Jquery 插件
- 多设备混合应用程序 - 有没有人让 android 的索引数据库插件工作
- 科尔多瓦 Phonegap 条形码插件无法从我的英特尔 XDK 应用程序启动
- 如何在 Angular 应用程序中绑定图形度量 jquery 插件