簡體   English   中英

RequireJS、Stripe 和依賴(Vue 組件)

[英]RequireJS, Stripe and dependency (Vue component)

我正在使用 Stripe 庫,並且我有一個依賴於首先加載的庫的 vue 組件。

我找到了 RequireJS (2.3.6) 並且從未使用過它,只是想知道我是否正確地做事

我嘗試使用此問題中的答案,但無法使用 Require.js 加載 Stripe.js

requirejs.config({
  paths: {
    'stripe': 'https://js.stripe.com/v3/'
  },
  shim: {
    'stripe': {
      exports: 'Stripe',
      deps:['my-component.js']
    }
  }
});

我沒有收到任何控制台錯誤,但我也沒有看到我的組件

我最終解決了

requirejs.config({
    shim: {
        form: {
            deps: [ 'stripe' ]
        }
    },
    paths: {
        stripe: 'https://js.stripe.com/v3/?noext',
        form: '/js/my-component'
    }
});

require(['stripe', 'form'], function($) { 
    return {};
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM