问题描述
我很难将Photoswipe与Aurelia集成在一起.我遇到了编译时错误和浏览器错误.我看了这个问题,尝试了那里提出的建议(除了更改打字文件之外,因为我不知道要更改什么),但仍然无法正常工作.利用来自其他问题的信息,我设法解决了编译时错误,但是在初始化Photoswipe时仍然出现错误:
I have a really hard time of integrating Photoswipe with Aurelia. I got compile time errors and browser errors.I looked at this question and tried what was suggested there (except the change of the typings file, because I don't know what to change), but still it is not working. With the information from the other question I managed to resolve the compile time errors but I still get an error when I initialize Photoswipe:
aurelia.json:
{
"name": "photoswipe",
"main": "photoswipe",
"path": "../node_modules/photoswipe/dist",
"resources": [
"photoswipe-ui-default.js"
]
}
package.json:
我在4.0.8版本中尝试了打字和照相擦拭,但没有任何变化.
I tried it with version 4.0.8 for both the typings and photoswipe, but no change.
"@types/photoswipe": "^4.0.27",
"photoswipe": "^4.1.2",
视图模型:
我需要将photoswipe-ui-default.js
复制到项目根目录中的以下文件夹中,因为如果没有'dist'
,则找不到(o_0)
我感到很奇怪,尽管它在aurelia.json中被引用为资源,但"photoswipe/photoswipe-ui-default.js"
无法找到它.
I needed to copy the photoswipe-ui-default.js
to the below folder in my project root, because without 'dist'
it could not be found (o_0)
I find it really strange that it cannot find it by "photoswipe/photoswipe-ui-default.js"
although it is referenced as a resource in aurelia.json.
import PhotoSwipe from "photoswipe";
import PhotoSwipeUI_Default from "photoswipe/dist/photoswipe-ui-default.js"
[...]
let pswpElement = <HTMLElement>document.querySelectorAll('.pswp')[0];
let gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, this.items, this.options);
有人可以帮助我吗?
推荐答案
import * as PhotoSwipe from "photoswipe";
import * as PhotoSwipeUI_Default from "photoswipe/photoswipe-ui-default"
这篇关于如何将Photoswipe与Aurelia合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!