小编ape*_*ena的帖子

Stripe() 的值无效:apiKey 应为字符串。您指定:未定义

我正在使用“Vue Stripe Checkout 3”组件,当我尝试实现它时,出现以下错误“

Invalid value for Stripe (): apiKey should be a string. You specified: undefined.
Run Code Online (Sandbox Code Playgroud)

在我的数据中我有:

publishableKey: process.env.PUBLISHABLE_KEY,
Run Code Online (Sandbox Code Playgroud)

我还尝试直接添加我的密钥(publishableKey:'我的密钥'),但它仍然不起作用。我也尝试过直接把它放在道具上,但什么也没有。

<template>
<div>
          <stripe-checkout 
          ref="checkoutRef" 
          :pk="publishableKey"
          :items="items"
          :successUrl="successUrl"
          :cancelUrl="cancelUrl">

    <template slot="checkout-button">
      <button @click="checkout" class="btn-yellow wow fadeInUp btn" style="visibility: visible; animation-name: fadeInUp;">Pagar</button>
    </template>
  </stripe-checkout>
       
</div>
</template>

<script>
import { StripeCheckout } from 'vue-stripe-checkout';

export default {
   components: {
    StripeCheckout
  },
   data: () => ({
    loading: false,
publishableKey: 'sk_test_51H85e2F5x69G5dDPxFEtO0RyIBWBEWkqwV9fpN5ovLysfCxJ15kfyeALoUFdZNi57yt0zj40h4LV3l5Zkra6WPCw00by0N0W3a',
    items: [
      {
        sku: item.sku, 
        quantity: 1
      }
    ],
    successUrl: 'https://tarfut.es',
    cancelUrl: 'https://tarfut.es', …
Run Code Online (Sandbox Code Playgroud)

javascript vue.js vuejs2

12
推荐指数
1
解决办法
2万
查看次数

Object.entries(),为什么我的数组默认按数字排序?

我正在编写一个简单的代码练习解决方案,并遇到了似乎object.entries()在进行内部数字升序排序的内容。我原以为必须自己对键值对进行排序,因为文档说如果您需要特定顺序,则必须进行排序。为什么会发生这种情况,我可以依赖这种行为吗?

/*
Given an input of [1,2,4,591,392,391,2,5,10,2,1,1,1,20,20], 
make a function that organizes these into individual array that is ordered. 
The above input should return:
[[1,1,1,1],[2,2,2],4,5,10,[20,20],391,392,591].
*/
const cleanTheRoom = (mess) => { 
  let hash = {};
  for (let i = 0; i < mess.length; i++) {
    (hash.hasOwnProperty(mess[i])) ? hash[mess[i]]++ : hash[mess[i]] = 1;
  }
  const clean = [];
  for (const [key, value] of Object.entries(hash)) {
    (value > 1) ? clean.push(Array(value).fill(key)) : clean.push(key);
  }
  return clean;
} …
Run Code Online (Sandbox Code Playgroud)

javascript

4
推荐指数
1
解决办法
72
查看次数

标签 统计

javascript ×2

vue.js ×1

vuejs2 ×1