【问题标题】:Aurelia with jquery.soap. How do I import and use the moduleAurelia 与 jquery.soap。如何导入和使用模块
【发布时间】:2017-07-01 06:10:11
【问题描述】:

我是 Aurelia 框架的新手。

我想调用一个 SOAP 网络服务,并找到模块 jquery.soap (https://www.npmjs.com/package/jquery.soap) 来处理它。

我已在 aurelia.json 的依赖项中添加了该模块

   ..."jquery",
      "jquery.soap",
      {
        "name": "bootstrap",
        "path": "../node_modules/bootstrap/dist",
        "main": "js/bootstrap.min",
        "deps": ["jquery"],
        "exports": "$",
        "resources": [
          "css/bootstrap.css"
        ]
      },...

现在我将它导入 app.ts 并尝试像这样使用它

import $ from "jquery.soap"

export class App {
 $.soap({
    url: 'http://my.server.com/soapservices/',
    method: 'helloWorld',

    data: {
        name: 'Remy Blom',
        msg: 'Hi!'
    },

    success: function (soapResponse) {
        console.log("success");
    },
    error: function (SOAPResponse) {
        console.log("error");
    }
 });
}

我的问题是它找不到模块“jquery.soap”... 那么问题来了,如何正确导入“jquery.soap”模块呢? 我也对使用该模块有疑问。应该用在 app.ts 还是 app.html 中?

【问题讨论】:

    标签: jquery soap npm aurelia


    【解决方案1】:

    只需导入插件:

    import 'jquery.soap';
    

    这在 js 中运行良好,在 ts 中您可能需要导入 jquery 以避免警告:

    import * as $ from 'jquery';
    import 'jquery.soap';
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-06
      • 2018-10-10
      • 2021-09-22
      • 1970-01-01
      • 2017-01-20
      • 2021-08-17
      • 1970-01-01
      • 2015-05-08
      相关资源
      最近更新 更多