【问题标题】:How to incorporate Photoswipe with Aurelia如何将 Photoswipe 与 Aurelia 结合使用
【发布时间】:2017-05-18 18:15:28
【问题描述】:

我很难将 Photoswipe 与 Aurelia 集成。我得到编译时错误和浏览器错误。 我查看了this question 并尝试了那里的建议(除了类型文件的更改,因为我不知道要更改什么),但它仍然无法正常工作。使用来自另一个问题的信息,我设法解决了编译时错误,但是在初始化 Photoswipe 时仍然出现错误:

未捕获的类型错误:photoswipe_1.default 不是构造函数

aurelia.json:

{
    "name": "photoswipe",
    "main": "photoswipe",
    "path": "../node_modules/photoswipe/dist",
    "resources": [
      "photoswipe-ui-default.js"
    ]
}

package.json:

我在 4.0.8 版本中尝试了打字和照片滑动,但没有任何变化。

"@types/photoswipe": "^4.0.27",
"photoswipe": "^4.1.2",

视图模型:

我需要将photoswipe-ui-default.js 复制到我的项目根目录中的以下文件夹,因为没有'dist' 无法找到它 (o_0)
我觉得很奇怪"photoswipe/photoswipe-ui-default.js" 找不到它,尽管它在 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);

谁能帮帮我?

【问题讨论】:

    标签: typescript aurelia photoswipe


    【解决方案1】:
    import * as PhotoSwipe from "photoswipe"; 
    import * as PhotoSwipeUI_Default from "photoswipe/photoswipe-ui-default"
    

    【讨论】:

    • 虽然此代码可能会回答问题,但提供有关它如何和/或为什么解决问题的额外上下文将提高​​答案的长期价值。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-11
    • 2012-04-01
    • 2017-06-13
    • 2019-02-09
    相关资源
    最近更新 更多