一个 Nuxt 模块,用于简化在项目中集成 Paypal。
nuxt-paypal 依赖项添加到您的项目中# Using pnpm
pnpm add -D nuxt-paypal
# Using yarn
yarn add --dev nuxt-paypal
# Using npm
npm install --save-dev nuxt-paypal
nuxt-paypal 添加到 nuxt.config.ts 的 modules 部分export default defineNuxtConfig({
modules: [
'nuxt-paypal',
],
paypal: {
clientId: 'your_client_id',
},
})
就这样!您现在可以在您的 Nuxt 应用程序中使用 Nuxt Paypal 了 ✨
只需添加 paypal 并进行配置。
默认情况下,
clientId配置为使用PAYPAL_CLIENT_ID的值。如果未提供特定值,则默认为test。
export default defineNuxtConfig({
paypal: {
clientId: 'your_client_id',
// ...options
},
})
nuxt-paypal 有一个 usePaypalButton 可组合项,您可以在此处查看其用法。
您还可以从 nuxtApp 中找到 paypal 实例,名为 $paypal。例如
<script setup lang="ts">
const nuxt = useNuxtApp()
console.log(nuxt.$paypal?.version)
</script>
# Install dependencies
npm install
# Generate type stubs
npm run dev:prepare
# Develop with the playground
npm run dev
# Build the playground
npm run dev:build
# Run ESLint
npm run lint
# Run Vitest
npm run test
npm run test:watch
# Release new version
npm run release