带有Jquery的VueJS

时间:2018-06-27 09:57:14

标签: javascript jquery django vue.js vue-component

伙计们,我的项目使用django和vueJS。我想用数字签名对文件签名。我的橱柜之一是django,所以我用jQuery脚本做了。现在,我想将此脚本导入我的vue代码。因此,用户可以单击按钮,它将调用signFile函数。我使用created在vue组件中创建了一些脚本标签。

  let es6Promise = document.createElement('script')
  es6Promise.setAttribute('src', '/static/etf/js/signing/es6-promise.min.js')
  document.head.appendChild(es6Promise)

  let ieEventlistnerPolyfill = document.createElement('script')
  ieEventlistnerPolyfill.setAttribute('src', '/static/etf/js/signing/ie_eventlistner_polyfill.js')
  document.head.appendChild(ieEventlistnerPolyfill)

  let firefoxCadespluginAsync = document.createElement('script')
  firefoxCadespluginAsync.setAttribute('src', '/static/etf/js/signing/firefox_cadesplugin_async.js')
  document.head.appendChild(firefoxCadespluginAsync)

  let cadespluginApi = document.createElement('script')
  cadespluginApi.setAttribute('src', '/static/etf/js/signing/cadesplugin_api.js')
  document.head.appendChild(cadespluginApi)

  let code = document.createElement('script')
  code.setAttribute('src', '/static/etf/js/signing/Code_js.js')
  document.head.appendChild(code)

  let signFileScript = document.createElement('script')
  signFileScript.setAttribute('src', '/static/etf/js/signing/signFile.js')
  document.head.appendChild(signFileScript)

我创建了按钮。 signFile函数位于signFile.js中。那么我该如何在点击事件时调用此函数?

1 个答案:

答案 0 :(得分:0)

您可以在signFile.js中加入index.html。之后,您的功能将在window对象上可用。

要使用signFile.js公开的方法,您可以编写如下内容

window.SignMethod(args)

在来自vuejs处理程序的回调中。

相关问题