2017-05-06 53 views

回答

0

stripe.elements接受一個選項對象。

stripe.elements([options]) 

fonts
An array of custom fonts Elements created from the elements object can use.

看來,它期待的數組。

嘗試更改爲

var elements = stripe.elements(
    { 
     fonts: [{ 
      family:'Effra', 
      src: "url('https://cuddlecompanions.org/wp-content/themes/diamondphoenix/fonts/effra.eot')" 
     }] 
    } 
); 
+0

感謝您的答覆。然而,沒有運氣..試圖在外{}之前的[]也.. Effra被用作iframe中的字體家族,只是沒有與任何東西定義(src ....簡單地用斜體和沒有任何東西) 任何幫助,將不勝感激 – user1367323

0

我認爲它是一個格式錯誤,你錯過了一些逗號。

var elements = stripe.elements({ 
      fonts: [ 
       { 
       family:'Effra', 
       src: "url('https://cuddlecompanions.org/wp-content/themes/diamondphoenix/fonts/effra.eot')", 
       }, 
      ] 
     }); 
3

謝謝你們的幫助。我在條紋的IRC上得到了幫助。它可能是缺少的逗號,並且也切換到了ttf。無論如何希望這可以幫助某人:

var elements = stripe.elements({ 
    fonts: [ 
     { 
      family: 'Effra', 

      src: 'local("Effra"), local("effra"), url(https://cuddlecompanions.org/wp-content/themes/diamondphoenix/fonts/effra.ttf) format("truetype")', 
      unicodeRange: 'U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215', 
     }, 
    ] 
}); 


<style> 
@font-face { 
font-family: 'Effra'; 
font-weight: 400; 
src: local("Effra"), local("effra"), url(https://cuddlecompanions.org/wp-content/themes/diamondphoenix/fonts/effra.ttf) format("truetype"); 
unicodeRange: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215; 
} 
</style> 
+0

嗨,夥計,你知道我該如何添加我的本地字體stripe.elements? 我收到此錯誤: 字體配置中的src值無效:/static/my-local-path/my-font.woff。 網址必須以'https://'或'data: – Giancarlos

+1

@Giancarlos'開始,因爲字體已加載到iFrame中,因此您需要指定完整路徑。 https://yoursite.com/static/my-local-path/my-font.woff。 – lcharbon